Loading .pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ repos: rev: v1.4.1 hooks: - id: mypy args: [--follow-imports=silent, kilter/protocol] args: [--follow-imports=silent, kilter/protocol, tests] pass_filenames: false additional_dependencies: - trio-typing Loading kilter/protocol/core.py +22 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ EventMessage: TypeAlias = Union[ Abort, ] """ Messages sent from an MTA to a filter Messages sent from an MTA to a filter to indicate an event occurrence """ ResponseMessage: TypeAlias = Union[ Loading Loading @@ -72,6 +72,25 @@ EditMessage: TypeAlias = Union[ Messages send from a filter to an MTA after an `EndOfMessage` to modify a message """ MTAMessage: TypeAlias = Union[ EventMessage, Negotiate, Close, ] """ All messages that can be sent from an MTA to a filter """ FilterMessage: TypeAlias = Union[ ResponseMessage, EditMessage, Negotiate, Skip, ] """ All messages that can be sent from a filter to an MTA """ class Unimplemented(messages.BytesMessage, ident=b"\x00"): """ Loading Loading @@ -194,7 +213,7 @@ class FilterProtocol: def read_from( self, buf: FixedSizeBuffer, ) -> Iterable[Negotiate|EventMessage|Close|Unimplemented]: ) -> Iterable[MTAMessage|Unimplemented]: """ Return an iterator yielding each complete message from a buffer Loading Loading @@ -223,7 +242,7 @@ class FilterProtocol: def write_to( self, buf: FixedSizeBuffer, message: ResponseMessage|EditMessage|Negotiate|Skip, message: FilterMessage, ) -> None: """ Validate and pack response and modification messages into a buffer Loading tests/example_filter.py +3 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import trio from kilter.protocol import messages from kilter.protocol.buffer import SimpleBuffer from kilter.protocol.core import FilterMessage from kilter.protocol.core import FilterProtocol from kilter.protocol.core import Unimplemented Loading Loading @@ -40,7 +41,7 @@ async def process_client(client: trio.SocketStream, nursery: trio.Nursery) -> No buf = SimpleBuffer(2**20) proto = FilterProtocol() send_channel, recv_channel = trio.open_memory_channel[messages.Message](4) send_channel, recv_channel = trio.open_memory_channel[FilterMessage](4) nursery.start_soon(client_sender, recv_channel, client, proto) async with client: Loading Loading @@ -70,7 +71,7 @@ async def process_client(client: trio.SocketStream, nursery: trio.Nursery) -> No async def client_sender( channel: trio.MemoryReceiveChannel[messages.Message], channel: trio.MemoryReceiveChannel[FilterMessage], client: trio.SocketStream, proto: FilterProtocol, ) -> None: Loading Loading
.pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ repos: rev: v1.4.1 hooks: - id: mypy args: [--follow-imports=silent, kilter/protocol] args: [--follow-imports=silent, kilter/protocol, tests] pass_filenames: false additional_dependencies: - trio-typing Loading
kilter/protocol/core.py +22 −3 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ EventMessage: TypeAlias = Union[ Abort, ] """ Messages sent from an MTA to a filter Messages sent from an MTA to a filter to indicate an event occurrence """ ResponseMessage: TypeAlias = Union[ Loading Loading @@ -72,6 +72,25 @@ EditMessage: TypeAlias = Union[ Messages send from a filter to an MTA after an `EndOfMessage` to modify a message """ MTAMessage: TypeAlias = Union[ EventMessage, Negotiate, Close, ] """ All messages that can be sent from an MTA to a filter """ FilterMessage: TypeAlias = Union[ ResponseMessage, EditMessage, Negotiate, Skip, ] """ All messages that can be sent from a filter to an MTA """ class Unimplemented(messages.BytesMessage, ident=b"\x00"): """ Loading Loading @@ -194,7 +213,7 @@ class FilterProtocol: def read_from( self, buf: FixedSizeBuffer, ) -> Iterable[Negotiate|EventMessage|Close|Unimplemented]: ) -> Iterable[MTAMessage|Unimplemented]: """ Return an iterator yielding each complete message from a buffer Loading Loading @@ -223,7 +242,7 @@ class FilterProtocol: def write_to( self, buf: FixedSizeBuffer, message: ResponseMessage|EditMessage|Negotiate|Skip, message: FilterMessage, ) -> None: """ Validate and pack response and modification messages into a buffer Loading
tests/example_filter.py +3 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import trio from kilter.protocol import messages from kilter.protocol.buffer import SimpleBuffer from kilter.protocol.core import FilterMessage from kilter.protocol.core import FilterProtocol from kilter.protocol.core import Unimplemented Loading Loading @@ -40,7 +41,7 @@ async def process_client(client: trio.SocketStream, nursery: trio.Nursery) -> No buf = SimpleBuffer(2**20) proto = FilterProtocol() send_channel, recv_channel = trio.open_memory_channel[messages.Message](4) send_channel, recv_channel = trio.open_memory_channel[FilterMessage](4) nursery.start_soon(client_sender, recv_channel, client, proto) async with client: Loading Loading @@ -70,7 +71,7 @@ async def process_client(client: trio.SocketStream, nursery: trio.Nursery) -> No async def client_sender( channel: trio.MemoryReceiveChannel[messages.Message], channel: trio.MemoryReceiveChannel[FilterMessage], client: trio.SocketStream, proto: FilterProtocol, ) -> None: Loading