tractor/tractor
Tyler Goodlet 213e083dc6 Proto `MsgCodec`, an interchange fmt modify API
Fitting in line with the issues outstanding:
- #36: (msg)spec-ing out our SCIPP (structured-con-inter-proc-prot).
  (https://github.com/goodboy/tractor/issues/36)

- #196: adding strictly typed IPC msg dialog schemas, more or less
  better described as "dialog/transaction scoped message specs"
  using `msgspec`'s tagged unions and custom codecs.
  (https://github.com/goodboy/tractor/issues/196)

- #365: using modern static type-annots to drive capability based
  messaging and RPC.
  (statically https://github.com/goodboy/tractor/issues/365)

This is a first draft of a new API for dynamically overriding IPC msg
codecs for a given interchange lib from any task in the runtime. Right
now we obviously only support `msgspec` but ideally this API holds
general enough to be used for other backends eventually (like
`capnproto`, and apache arrow).

Impl is in a new `tractor.msg._codec` with:
- a new `MsgCodec` type for encapsing `msgspec.msgpack.Encoder/Decoder`
  pairs and configuring any custom enc/dec_hooks or typed decoding.
- factory `mk_codec()` for creating new codecs ad-hoc from a task.
- `contextvars` support for a new `trio.Task` scoped
  `_ctxvar_MsgCodec: ContextVar[MsgCodec]` named 'msgspec_codec'.
- `apply_codec()` for temporarily modifying the above per task
  as needed around `.open_context()` / `.open_stream()` operation.

A new test (suite) in `test_caps_msging.py`:
- verify a parent and its child can enable the same custom codec (in
  this case to transmit `NamespacePath`s) with tons of pedantic ctx-vars
  checks.
- ToDo: still need to implement #36 msg types in order to be able to get
  decodes working (as in `MsgStream.receive()` will deliver an already
  created `NamespacePath` obj) since currently all msgs come packed in `dict`-msg
  wrapper packets..
  -> use the proto from PR #35 to get nested `msgspec.Raw` processing up
  and running Bo
2025-03-24 14:04:33 -04:00
..
_testing Add (back) a `tractor._testing` sub-pkg 2025-03-16 15:28:28 -04:00
devx Mask not-yet-existing `.devx.pformat` import 2025-03-21 00:18:05 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
msg Proto `MsgCodec`, an interchange fmt modify API 2025-03-24 14:04:33 -04:00
trionics Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
__init__.py Use `import <name> as <name>,` style over `__all__` in pkg mod 2025-03-20 19:50:31 -04:00
_child.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
_clustering.py Passthrough runtime kwargs from `open_actor_cluster()` 2022-12-11 19:56:08 -05:00
_context.py Add todo-notes for hiding `@acm` frames 2025-03-20 22:37:51 -04:00
_discovery.py More spaceless union type annots 2025-03-20 19:50:31 -04:00
_entry.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
_exceptions.py Lul, don't overwrite 'tb_str' with src actor's.. 2025-03-20 20:35:02 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py Proto `MsgCodec`, an interchange fmt modify API 2025-03-24 14:04:33 -04:00
_mp_fixup_main.py Avoid importing mp for as long as possible 2022-02-17 11:55:26 -05:00
_multiaddr.py Fix doc string "its" typo.. 2025-03-20 19:50:31 -04:00
_portal.py Init-support for "multi homed" transports 2025-03-20 19:50:31 -04:00
_root.py Add `enable_stack_on_sig: bool` for `stackscope` toggle 2025-03-20 23:22:45 -04:00
_rpc.py Refine and test `tractor.pause_from_sync()` 2025-03-20 22:37:51 -04:00
_runtime.py Change all `| None` -> `|None` in `._runtime` 2025-03-20 22:37:51 -04:00
_spawn.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
_state.py Add defaul rtv for `use_greeback: bool = False` 2025-03-20 23:22:45 -04:00
_streaming.py Absorb EoCs via `Context.open_stream()` silently 2025-03-16 16:06:26 -04:00
_supervise.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
log.py Bleh, make `log.devx()` level less then cancel but > `.runtime()` 2025-03-20 23:22:45 -04:00
to_asyncio.py Provision for infected-`asyncio` debug mode support 2025-03-20 22:37:51 -04:00