class InMemoryBroker
implements MessageBrokerAdapter
Since 0.1.0

In-memory message broker implementation.

Provides fanout delivery to subscribers without a queue, and load-balanced (round-robin) delivery to subscribers within a queue.

Constructors

InMemoryBroker(
runtime: IRuntimeServices,
serializer: ISerializer,
)

Creates a new in-memory broker.

Parameters
runtime: IRuntimeServices

Runtime services for uuid, timestamps, and timers

serializer: ISerializer

Serializer for message payloads

optional
options: InMemoryBrokerOptions

Optional behaviour, currently the dispatch-error reporter

Methods

Since 0.1.0
connect(): Promise<void>

Connects the broker (idempotent no-op for in-memory).

Since 0.1.0
disconnect(): Promise<void>

Disconnects the broker and clears all subscriptions.

Since 0.1.0
isHealthy(): Promise<boolean>

Boolean port member (M70c).

Since 0.1.0
isReady(): boolean

Checks if the broker is connected.

Since 0.1.0
publish<T>(
topic: string,
message: T
): Promise<void>

Publishes a message to a topic.

Delivers to all subscribers without a queue (fanout), and to one subscriber per queue (round-robin load balancing).

publishWithHeaders<T>(
topic: string,
message: T,
headers: Readonly<Record<string, string>>
): Promise<void>

Publishes a message with framework-owned transport headers. Resolves on dispatch hand-off (see publish); each invoked handler's promise is RETAINED and its rejection routed to the failure path below — never dropped, never unhandled. @internal

Since 0.1.0
reachability(): Promise<boolean>

Tri-state backend reachability (M70c).

There is no backend to be unreachable: the bus is in-process, so the answer is simply whether the broker is running. true while ready, false before connect() or after disconnect().

Since 0.1.0
request<TReq, TRes>(
topic: string,
message: TReq,
options?: RequestOptions
): Promise<TRes>

Sends a request and awaits a single correlated reply.

requestWithHeaders<TReq, TRes>(
topic: string,
message: TReq,
headers: Readonly<Record<string, string>>,
options?: RequestOptions
): Promise<TRes>

Sends request-reply traffic with framework-owned headers. @internal

Since 0.1.0
respond<TReq, TRes>(
topic: string,
handler: RequestHandler<TReq, TRes>,
): Promise<ISubscription>

Registers a responder whose result is returned to the requesting caller.

Since 0.1.0
subscribe<T>(
topic: string,
handler: MessageHandler<T>,
): Promise<ISubscription>

Subscribes to a topic.

subscribeWithHeaders<T>(
topic: string,
handler: MessageHandler<T>,
): Promise<ISubscription>

Subscribes through the header-aware internal path. @internal