pynenc.broker.base_broker¶
Module Contents¶
Classes¶
Abstract base class for message brokers in Pynenc’s plugin system. |
API¶
- class pynenc.broker.base_broker.BaseBroker(app: pynenc.app.Pynenc)[source]¶
Bases:
abc.ABCAbstract base class for message brokers in Pynenc’s plugin system.
Routes task invocations through a message queue system, supporting both FIFO and priority-based queuing depending on the implementation.
- Parameters:
app (Pynenc) – A reference to the Pynenc application instance.
Initialization
- abstractmethod route_invocation(invocation_id: pynenc.identifiers.invocation_id.InvocationId) None[source]¶
Abstract method for routing a given invocation id.
This method should define the process of handling and dispatching a given invocation id within the broker system. Implementations might involve sending the invocation to a queue or handling it internally.
- Parameters:
invocation_id (InvocationId) – The invocation id to be routed.
- abstractmethod route_invocations(invocation_ids: list[pynenc.identifiers.invocation_id.InvocationId]) None[source]¶
Routes multiple invocations at once.
This method is used for batch processing of invocations to improve performance when parallelizing large numbers of tasks.
Default implementation sequentially routes each invocation. Subclasses can override this with more efficient batch processing implementations.
- Parameters:
invocation_ids (list[“InvocationId”]) – The invocation ids to be routed.
- abstractmethod retrieve_invocation() InvocationId | None[source]¶
Method to retrieve a distributed invocation id.
Implementations of this method should detail how to retrieve the next available invocation from the broker’s queue or storage system. It is expected to return a invocation id if one is available, or None if the queue is empty.
- Returns:
The next invocation id to be processed, or None.
- abstractmethod count_invocations() int[source]¶
Method to count the number of invocations in the queue.
This method should return the current count of pending invocations in the broker’s queue. It’s useful for monitoring and managing the queue’s state.
- Returns:
The number of invocations in the queue.