InMemoryMessageStateStore
Sub classes
| Name |
Children |
Inherits |
DebuggingMessageStateStore aclientp.task.debug Enhanced message state store with structured debugging output. |
|
|
Base classes
| Name |
Children |
Inherits |
MessageStateStore aclientp.task.state Protocol for managing message states. |
|
|
⋔ Inheritance diagram
graph TD
95970862936224["state.InMemoryMessageStateStore"]
95970860557536["state.MessageStateStore"]
95970836711072["typing.Protocol"]
95970835676112["typing.Generic"]
125067848591872["builtins.object"]
95970860557536 --> 95970862936224
95970836711072 --> 95970860557536
95970835676112 --> 95970836711072
125067848591872 --> 95970835676112
🛈 DocStrings
Bases: MessageStateStore
In-memory implementation of MessageStateStore.
Source code in src/aclientp/task/state.py
| class InMemoryMessageStateStore(MessageStateStore):
"""In-memory implementation of MessageStateStore."""
def __init__(self) -> None:
self._outgoing: dict[int, OutgoingMessage] = {}
self._incoming: list[IncomingMessage] = []
def register_outgoing(self, request_id: int, method: str) -> asyncio.Future[Any]:
future: asyncio.Future[Any] = asyncio.get_running_loop().create_future()
self._outgoing[request_id] = OutgoingMessage(request_id, method, future)
return future
def resolve_outgoing(self, request_id: int, result: Any) -> None:
record = self._outgoing.pop(request_id, None)
if record and not record.future.done():
record.future.set_result(result)
def reject_outgoing(self, request_id: int, error: RequestError) -> None:
record = self._outgoing.pop(request_id, None)
if record and not record.future.done():
record.future.set_exception(error)
def reject_all_outgoing(self, error: BaseException) -> None:
for record in self._outgoing.values():
if not record.future.done():
record.future.set_exception(error)
self._outgoing.clear()
def begin_incoming(self, method: str, params: Any) -> IncomingMessage:
record = IncomingMessage(method=method, params=params)
self._incoming.append(record)
return record
def complete_incoming(self, record: IncomingMessage, result: Any) -> None:
record.status = "completed"
record.result = result
def fail_incoming(self, record: IncomingMessage, error: Exception) -> None:
record.status = "failed"
record.error = error
|
:fa-brands-github: Show source on GitHub