pynenc_redis.broker.redis_broker

Module Contents

Classes

RedisBroker

A Redis-backed implementation of the BaseBroker.

API

class pynenc_redis.broker.redis_broker.RedisBroker(app: pynenc.app.Pynenc)[source]

Bases: pynenc.broker.base_broker.BaseBroker

A Redis-backed implementation of the BaseBroker.

This subclass of BaseBroker implements the abstract methods for routing, retrieving, and purging invocations using Redis as the message broker. It is suitable for production environments where robustness and scalability are required.

Parameters:

app (Pynenc) – A reference to the Pynenc application.

Initialization

property client: redis.Redis

Lazy initialization of Redis client

conf() pynenc_redis.conf.config_broker.ConfigBrokerRedis
route_invocation(invocation_id: pynenc.identifiers.invocation_id.InvocationId) None[source]

Route an invocation by sending it to the Redis queue.

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

Routes multiple invocations at once using Redis pipeline for better performance.

retrieve_invocation() InvocationId | None[source]

Retrieve the next invocation from the Redis queue.

count_invocations() int[source]

Get the number of invocations in the Redis queue.

This method queries the Redis queue for the number of messages currently in the queue.

Returns:

The number of invocations in the queue.

purge() None[source]

Purge all invocations from the Redis queue.

This method delegates to the purge method of the RedisQueue to clear all messages.