Skip to content

Messaging

rn_forge.commons.integration.messaging

Messaging protocols: a transport-agnostic publish interface.

No delivery guarantees are implied. publish is fire-and-forget from the protocol's point of view — retries, at-least-once delivery, and transactional outbox semantics are the caller's responsibility.

AsyncMessageBus

Bases: Protocol

The async counterpart of :class:MessageBus.

publish(destination, event) async

Publish event to destination. Fire-and-forget; no delivery guarantee.

HandlerRegistry()

Maps a message type to its handler. Instantiable — no module-level registry.

handler_for(message_type)

Return the handler registered for message_type, or None.

register(message_type, handler)

Register handler for message_type. Returns self for chaining.

Raises:

Type Description
ValueError

message_type is already registered.

InMemoryMessageBus()

Records published events in memory. The test double, and the local default.

published property

A snapshot of every (destination, event) pair published so far, in order.

clear()

Discard every recorded publish.

publish(destination, event)

Record (destination, event) in publish order.

MessageBus

Bases: Protocol

A synchronous publish target for a named destination.

publish(destination, event)

Publish event to destination. Fire-and-forget; no delivery guarantee.