pynenc_mongo.broker.mongo_broker

Module Contents

Classes

BrokerCollections

MongoDB collections for the broker message queue.

MongoBroker

A MongoDB-based implementation of the broker for cross-process coordination.

API

class pynenc_mongo.broker.mongo_broker.BrokerCollections(conf: pynenc_mongo.conf.config_mongo.ConfigMongo, app_id: str)[source]

Bases: pynenc_mongo.util.mongo_collections.MongoCollections

MongoDB collections for the broker message queue.

Initialization

broker_message_queue() pynenc_mongo.util.mongo_client.RetryableCollection
class pynenc_mongo.broker.mongo_broker.MongoBroker(app: pynenc.app.Pynenc)[source]

Bases: pynenc.broker.base_broker.BaseBroker

A MongoDB-based implementation of the broker for cross-process coordination.

Uses MongoDB for cross-process message queue coordination and implements all required abstract methods from BaseBroker. Routes invocation IDs through a persistent FIFO queue stored in MongoDB.

Initialization

conf() pynenc_mongo.conf.config_broker.ConfigBrokerMongo
route_invocation(invocation_id: str) None[source]

Route a single invocation ID to the message queue.

Parameters:

invocation_id – The invocation ID to route

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

Route multiple invocation IDs to the message queue.

Parameters:

invocation_ids – List of invocation IDs to route

retrieve_invocation() InvocationId | None[source]

Atomically retrieve and remove a single invocation ID from the queue.

Ensures that no two processes can retrieve the same invocation.

Returns:

The next invocation ID in the queue, or None if empty

count_invocations() int[source]

Count the number of invocations in the queue.

Returns:

Number of pending invocations

purge() None[source]

Clear all messages from the queue.