← Open source

observer-pattern

PythonRabbitMQRedisPydanticPydantic

observer-pattern (published as eventforge) is a message-driven execution and event library.

Example

from eventforge import task, MessageQueue, Executor, ExecutionMode

queue = MessageQueue()
executor = Executor(mode=ExecutionMode.THREAD)

@task(
    queue=queue,
    topic="process.data",
    executor=executor,
    on_success=lambda ctx: print(ctx.result),
)
def process_data(data):
    return data.upper()

process_data("hello")                    # direct call -> "HELLO"
queue.publish("process.data", "world")   # same path, async via the queue

Components

The Observable / Eventful / Dispatcher core lets any object emit events. On top sit a topic-keyed MessageQueue (pub/sub with Pydantic-validated messages and a request/reply pattern), a competing-consumer WorkQueue with ack / nack / dead-letter, and an Executor that runs work sequentially, across threads, or across processes. A single @task decorator makes a function callable both directly and through the queue, with the same on_execute / on_success / on_failure / on_complete hooks. RPCServer / RPCClient layer remote procedure calls on the queue, and a RemoteQueue bridges nodes over TCP; built-in Meter and Reporter observers profile timing, metrics, memory and CPU without touching task code. It pairs with registry-pattern for serialization.