Class RedisEventBus
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
redisIConnectionMultiplexerloggerILogger<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
evtGatewayEventctCancellationToken
Returns
StreamAsync(string?, CancellationToken)
Returns an async enumerable of events for streaming scenarios.
public IAsyncEnumerable<GatewayEvent> StreamAsync(string? eventTypeFilter, CancellationToken ct = default)
Parameters
eventTypeFilterstringctCancellationToken
Returns
Subscribe(string?, Func<GatewayEvent, Task>)
Subscribes to events matching the given filter.
public IDisposable Subscribe(string? eventTypeFilter, Func<GatewayEvent, Task> handler)
Parameters
eventTypeFilterstringhandlerFunc<GatewayEvent, Task>