Extension types support via msgspec.Encoder/Decoder hooks #19
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "ext_type_plds"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Primary new-feature summary
Namely, extension-types as
msgspec.Structfields such that you can now (more) easily define and configuredec/enc_hook()funcs to be used by ourtractor.msg.MsgCodec/Decinternals:c302b74008Finally get type-extendedmsgspecfields workinnPldRxdesign we can,dec_hook()to ourMsgDecwhich is used to configure the underlying.dec: msgspec.msgpack.Decoderenc_hook()tomk_codec()and use it to conf the equivMsgCodec.encsuch that sent msg-plds are converted prior to transport.29c3895Namely movingenc/dec_type_union()from the test mod to a newtractor.msg._extsfor use everywhere.08e15f441Raise RTE fromlimit_plds()on nocurr_ctxVarious (and some very serious) fixes to the
tractor.msgrelated underbelly,e57ac63f56Avoid attr-err whenMsgTypeError._ipc_msg==Noneon sender side.fde6d84Fix msg-draining onparent_never_opened_stream!b0ab77aSlightPldRxrework to simplify, like01b5955AddContext._outcome_msguse newPldRxAPI51f7280AddMsgStream._stop_msguse newPldRxAPI4d9f6e73Supportctx: UnionTypeannots for@tractor.contextepsef7a585Deliver aMaybeBoxedErrorfrom.expect_ctxc()Testing related fixes & improvements,
b6e49029reworked test suitetest_ext_types_msgspec.py,test_ext_types_over_ipcwhich avoids all the wacky “parent dictates what sender should be able to send beforehand”, instead37b8d77Extend ctx semantics suite for streaming edge cases!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).b85f301c05to8d12ece8d68d12ece8d6to6b8bd950fb6b8bd950fbtoeb12029372Fyi prior to this landing the
mainbranch should have the following failures (see screenshot) since obvi this patchset reworks that suite entirely.Lol woops meant for this to be switched to
main..Just did the
git merge --no-ffmanually and added the same commit msg thatgiteawould’veBp