Table of Contents

Class InProcessEventBus

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

In-process event bus backed by Channel<T>. Suitable for single-process gateway; replace with a distributed implementation (Redis Pub/Sub, Azure Service Bus, etc.) for multi-node.

public sealed class InProcessEventBus : IEventBus, IDisposable
Inheritance
InProcessEventBus
Implements
Inherited Members

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

PublishAsync(GatewayEvent, CancellationToken)

Publishes an event to all subscribers.

public 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.

public 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.

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

Parameters

eventTypeFilter string
handler Func<GatewayEvent, Task>

Returns

IDisposable