forked from goodboy/tractor
1
0
Fork 0

Rename `.msg.types.Msg` -> `PayloadMsg`

runtime_to_msgspec
Tyler Goodlet 2024-05-10 13:15:45 -04:00
parent d2dee87b36
commit 236083b6e4
3 changed files with 15 additions and 15 deletions

View File

@ -44,7 +44,7 @@ from ._codec import (
# ) # )
from .types import ( from .types import (
Msg as Msg, PayloadMsg as PayloadMsg,
Aid as Aid, Aid as Aid,
SpawnSpec as SpawnSpec, SpawnSpec as SpawnSpec,

View File

@ -432,7 +432,7 @@ class MsgCodec(Struct):
# ) -> Any|Struct: # ) -> Any|Struct:
# msg: Msg = codec.dec.decode(msg) # msg: PayloadMsg = codec.dec.decode(msg)
# payload_tag: str = msg.header.payload_tag # payload_tag: str = msg.header.payload_tag
# payload_dec: msgpack.Decoder = codec._payload_decs[payload_tag] # payload_dec: msgpack.Decoder = codec._payload_decs[payload_tag]
# return payload_dec.decode(msg.pld) # return payload_dec.decode(msg.pld)

View File

@ -302,7 +302,7 @@ class StartAck(
class Started( class Started(
Msg, PayloadMsg,
Generic[PayloadT], Generic[PayloadT],
): ):
''' '''
@ -316,12 +316,12 @@ class Started(
# TODO: instead of using our existing `Start` # TODO: instead of using our existing `Start`
# for this (as we did with the original `{'cmd': ..}` style) # for this (as we did with the original `{'cmd': ..}` style)
# class Cancel(Msg): # class Cancel:
# cid: str # cid: str
class Yield( class Yield(
Msg, PayloadMsg,
Generic[PayloadT], Generic[PayloadT],
): ):
''' '''
@ -348,7 +348,7 @@ class Stop(
# TODO: is `Result` or `Out[come]` a better name? # TODO: is `Result` or `Out[come]` a better name?
class Return( class Return(
Msg, PayloadMsg,
Generic[PayloadT], Generic[PayloadT],
): ):
''' '''
@ -360,7 +360,7 @@ class Return(
class CancelAck( class CancelAck(
Msg, PayloadMsg,
Generic[PayloadT], Generic[PayloadT],
): ):
''' '''
@ -466,14 +466,14 @@ def from_dict_msg(
# TODO: should be make a msg version of `ContextCancelled?` # TODO: should be make a msg version of `ContextCancelled?`
# and/or with a scope field or a full `ActorCancelled`? # and/or with a scope field or a full `ActorCancelled`?
# class Cancelled(Msg): # class Cancelled(MsgType):
# cid: str # cid: str
# TODO what about overruns? # TODO what about overruns?
# class Overrun(Msg): # class Overrun(MsgType):
# cid: str # cid: str
_runtime_msgs: list[Msg] = [ _runtime_msgs: list[Struct] = [
# identity handshake on first IPC `Channel` contact. # identity handshake on first IPC `Channel` contact.
Aid, Aid,
@ -499,9 +499,9 @@ _runtime_msgs: list[Msg] = [
] ]
# the no-outcome-yet IAC (inter-actor-communication) sub-set which # the no-outcome-yet IAC (inter-actor-communication) sub-set which
# can be `Msg.pld` payload field type-limited by application code # can be `PayloadMsg.pld` payload field type-limited by application code
# using `apply_codec()` and `limit_msg_spec()`. # using `apply_codec()` and `limit_msg_spec()`.
_payload_msgs: list[Msg] = [ _payload_msgs: list[PayloadMsg] = [
# first <value> from `Context.started(<value>)` # first <value> from `Context.started(<value>)`
Started, Started,
@ -544,8 +544,8 @@ def mk_msg_spec(
] = 'indexed_generics', ] = 'indexed_generics',
) -> tuple[ ) -> tuple[
Union[Type[Msg]], Union[MsgType],
list[Type[Msg]], list[MsgType],
]: ]:
''' '''
Create a payload-(data-)type-parameterized IPC message specification. Create a payload-(data-)type-parameterized IPC message specification.
@ -557,7 +557,7 @@ def mk_msg_spec(
determined by the input `payload_type_union: Union[Type]`. determined by the input `payload_type_union: Union[Type]`.
''' '''
submsg_types: list[Type[Msg]] = Msg.__subclasses__() submsg_types: list[MsgType] = Msg.__subclasses__()
bases: tuple = ( bases: tuple = (
# XXX NOTE XXX the below generic-parameterization seems to # XXX NOTE XXX the below generic-parameterization seems to
# be THE ONLY way to get this to work correctly in terms # be THE ONLY way to get this to work correctly in terms