pynenc.broker.mem_broker¶
Module Contents¶
Classes¶
An in-memory implementation of the BaseBroker. |
API¶
- class pynenc.broker.mem_broker.MemBroker(app: pynenc.app.Pynenc)[source]¶
Bases:
pynenc.broker.base_broker.BaseBrokerAn in-memory implementation of the BaseBroker.
This subclass of BaseBroker implements the abstract methods for routing, retrieving, and purging invocations using an in-memory deque. It’s primarily intended for testing and demonstration purposes.
Warning
The
MemBrokerclass generates the queue in the process’s memory and is not suitable for production systems. Its use should be limited to testing or demonstration purposes only.- Parameters:
app (Pynenc) – A reference to the Pynenc application.
Initialization
- route_invocation(invocation: pynenc.invocation.dist_invocation.DistributedInvocation) None[source]¶
Route an invocation by adding it to the in-memory queue.
This method serializes the DistributedInvocation object to JSON and appends it to the deque, effectively queuing it for processing.
- Parameters:
invocation (DistributedInvocation) – The invocation to be queued.
- route_invocations(invocations: list[pynenc.invocation.dist_invocation.DistributedInvocation]) None[source]¶
Routes multiple invocations at once.
- Parameters:
invocations (list[DistributedInvocation]) – The invocations to be routed.
- retrieve_invocation() Optional[pynenc.invocation.dist_invocation.DistributedInvocation][source]¶
Retrieve the next invocation from the queue.
This method pops the next item from the deque, deserializes it from JSON, and returns the DistributedInvocation object. If the queue is empty, it returns None.
- Returns:
The next invocation from the queue, or None if the queue is empty.