Table of Contents

Class RedisEventBus

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

Distributed event bus backed by Redis Pub/Sub. Publishes events to a Redis channel so all connected nodes receive them; local subscriptions are dispatched in-process.

public sealed class RedisEventBus : IEventBus, IAsyncDisposable, IDisposable
Inheritance
RedisEventBus
Implements
Inherited Members

Constructors

RedisEventBus(IConnectionMultiplexer, ILogger<RedisEventBus>)

public RedisEventBus(IConnectionMultiplexer redis, ILogger<RedisEventBus> logger)

Parameters

redis IConnectionMultiplexer
logger ILogger<RedisEventBus>

Methods

Dispose()

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

public void Dispose()

DisposeAsync()

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

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

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