pynenc.broker.mem_broker

Module Contents

Classes

MemBroker

An in-memory implementation of the BaseBroker.

API

class pynenc.broker.mem_broker.MemBroker(app: pynenc.app.Pynenc)[source]

Bases: pynenc.broker.base_broker.BaseBroker

An 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 MemBroker class 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_id: pynenc.identifiers.invocation_id.InvocationId) None[source]

Route an invocation id by adding it to the in-memory queue.

This method appends the invocation ID to the deque, effectively queuing it for processing.

Parameters:

invocation_id (InvocationId) – The ID of the invocation to be queued.

route_invocations(invocation_ids: list[pynenc.identifiers.invocation_id.InvocationId]) None[source]

Routes multiple invocation IDs at once.

Parameters:

invocation_ids (list[InvocationId]) – The invocation IDs to be routed.

retrieve_invocation() InvocationId | None[source]

Retrieve the next invocation id from the queue.

This method pops the next item from the deque and returns the invocation ID. If the queue is empty, it returns None.

Returns:

The next invocation id from the queue, or None if the queue is empty.

Return type:

InvocationId | None

count_invocations() int[source]

Get the number of invocations in the in-memory queue.

purge() None[source]

Clear all invocations from the in-memory queue.

This method empties the deque, removing all pending invocations.