Interface IEventSubscription
- Namespace
- Excalibur.EventSourcing.Subscriptions
- Assembly
- Excalibur.EventSourcing.dll
Represents a subscription to a stream of domain events.
public interface IEventSubscription
Remarks
Event subscriptions provide a push-based mechanism for receiving new events as they are appended to a stream. Subscriptions automatically track their position and deliver events in order.
Call SubscribeAsync(string, Func<IReadOnlyList<IDomainEvent>, Task>, CancellationToken) to start receiving events and UnsubscribeAsync(CancellationToken) to stop.
Methods
SubscribeAsync(string, Func<IReadOnlyList<IDomainEvent>, Task>, CancellationToken)
Subscribes to events on the specified stream, delivering batches to the handler.
Task SubscribeAsync(string streamId, Func<IReadOnlyList<IDomainEvent>, Task> handler, CancellationToken cancellationToken)
Parameters
streamIdstringThe stream identifier to subscribe to.
handlerFunc<IReadOnlyList<IDomainEvent>, Task>The handler that processes batches of domain events. Events are delivered in order.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
A task representing the subscription setup.
UnsubscribeAsync(CancellationToken)
Unsubscribes from the event stream, stopping event delivery.
Task UnsubscribeAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
A task representing the unsubscribe operation.