Table of Contents

Interface IEventBus

Namespace
JD.AI.Core.Events
Assembly
JD.AI.Core.dll

Publish/subscribe event bus for cross-cutting gateway events.

public interface IEventBus

Methods

GetEvents(CancellationToken)

Returns a snapshot of all currently buffered events, oldest first. Only implemented by in-process transports; distributed transports throw.

Task<GatewayEvent[]> GetEvents(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<GatewayEvent[]>

PublishAsync(GatewayEvent, CancellationToken)

Publishes an event to all subscribers.

Task PublishAsync(GatewayEvent evt, CancellationToken ct = default)

Parameters

evt GatewayEvent
ct CancellationToken

Returns

Task

StreamAsync(string?, CancellationToken)

Returns an async enumerable of events for streaming scenarios.

IAsyncEnumerable<GatewayEvent> StreamAsync(string? eventTypeFilter, CancellationToken ct = default)

Parameters

eventTypeFilter string
ct CancellationToken

Returns

IAsyncEnumerable<GatewayEvent>

Subscribe(string?, Func<GatewayEvent, Task>)

Subscribes to events matching the given filter.

IDisposable Subscribe(string? eventTypeFilter, Func<GatewayEvent, Task> handler)

Parameters

eventTypeFilter string
handler Func<GatewayEvent, Task>

Returns

IDisposable