1
0
Fork 0
tractor/tractor
Tyler Goodlet 64fe767647 Finally get type-extended `msgspec` fields workinn
By using our new `PldRx` design we can,
- pass through the pld-spec & a `dec_hook()` to our `MsgDec` which is
  used to configure the underlying `.dec: msgspec.msgpack.Decoder`
- pass through a `enc_hook()` to `mk_codec()` and use it to conf the
  equiv `MsgCodec.enc` such that sent msg-plds are converted prior
  to transport.

The trick ended up being just to always union the `mk_dec()`
extension-types spec with the normaly with the `msgspec.Raw` pld-spec
such that the `dec_hook()` is only invoked for payload types tagged
by the encoder/sender side B)

A variety of impl tweaks to make it all happen as well as various
cleanups in the `.msg._codec` mod include,

- `mk_dec()` no defaul `spec` arg, better doc string, accept the new
  `ext_types` arg, doing the union of that with `msgspec.Raw`.
- proto-ed a now unused `mk_boxed_ext_struct()` which will likely get
  removed since it ended up that our `PayloadMsg` structs already cover
  the ext-type-hook requirement that the decoder is passed
  a `.type=msgspec.Struct` of some sort in order for `.dec_hook` to be
  used.
- add a `unpack_spec_types()` util fn for getting the `set[Type]` from
  from a `Union[Type]` annotation instance.
- mk the default `mk_codec(pc_pld_spec = Raw,)` since the `PldRx` design
  was already passing/overriding it and it doesn't make much sense to
  use `Any` anymore for the same reason; it will cause various `Context`
  apis to now break.
  |_ also accept a `enc_hook()` and `ext_types` which are used to maybe
     config the `.msgpack.Encoder`
- generally tweak a bunch of comments-as-docs and todos namely the ones
  that are completed after the pld-rx design was implemented.

Also,
- mask the non-functioning `'defstruct'` approach `inside
  `.msg.types.mk_msg_spec()` to prep for its removal.

Adjust the test suite (rn called `test_caps_based_msging`),
- add a new suite `test_custom_extension_types` and move and
  use the `enc/dec_nsp()` hooks to the mod level for its use.
- prolly planning to drop the `test_limit_msgspec` suite since it's
  mostly replaced by the `test_pldrx_limiting` mod's version?
- originally was tweaking a bunch in `test_codec_hooks_mod` but likely
  it will get mostly rewritten to be simpler and simply verify that
  ext-typed fields can be used over IPC `Context`s between actors (as
  originally intended for this sub-suite).
2025-03-27 15:58:02 -04:00
..
_testing Disable tb colors in `._testing.mk_cmd()` 2025-03-27 13:38:47 -04:00
devx Match `maybe_open_crash_handler()` to non-maybe version 2025-03-27 13:38:47 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
msg Finally get type-extended `msgspec` fields workinn 2025-03-27 15:58:02 -04:00
trionics Use `collapse_eg()` in broadcaster suite 2025-03-27 13:38:47 -04:00
__init__.py Mask top level import of `.hilevel` 2025-03-27 15:57:44 -04:00
_child.py Hide `._entry`/`._child` frames, tweak some more type annots 2025-03-20 23:22:45 -04:00
_clustering.py Clean up some imports in `._clustering` 2025-03-27 13:38:47 -04:00
_context.py Support `ctx: UnionType` annots for `@tractor.context` eps 2025-03-27 15:56:39 -04:00
_discovery.py Finally implement peer-lookup optimization.. 2025-03-24 14:04:52 -04:00
_entry.py Log format tweaks for sclang reprs 2025-03-27 13:38:47 -04:00
_exceptions.py Unpack errors from `pdb.bdb` 2025-03-27 13:38:47 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py Moar sclang log fmting tweaks 2025-03-27 13:38:47 -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 A couple more loose-egs flag flips 2025-03-27 13:38:47 -04:00
_root.py Expose `hide_tb: bool` from `.open_nursery()` 2025-03-27 13:38:47 -04:00
_rpc.py Moar sclang log fmting tweaks 2025-03-27 13:38:47 -04:00
_runtime.py Go to loose egs in `Actor` root & service nurseries (for now..) 2025-03-27 13:38:47 -04:00
_spawn.py Log format tweaks for sclang reprs 2025-03-27 13:38:47 -04:00
_state.py Moar sclang log fmting tweaks 2025-03-27 13:38:47 -04:00
_streaming.py Moar sclang log fmting tweaks 2025-03-27 13:38:47 -04:00
_supervise.py Hide `open_nursery()` frame by def 2025-03-27 13:38:47 -04:00
log.py Support passing pre-conf-ed `Logger` 2025-03-27 13:24:25 -04:00
to_asyncio.py Continue supporting py3.11+ 2025-03-27 13:24:25 -04:00