50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Abstractions.EventStore;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Subscriptions;
|
|
|
|
/// <summary>
|
|
/// Service responsible for delivering events to persistent subscriptions.
|
|
/// </summary>
|
|
public interface IPersistentSubscriptionDeliveryService
|
|
{
|
|
/// <summary>
|
|
/// Deliver an event to all matching subscriptions for a correlation ID.
|
|
/// </summary>
|
|
/// <param name="correlationId">The correlation ID to match subscriptions against.</param>
|
|
/// <param name="event">The event to deliver.</param>
|
|
/// <param name="sequence">The sequence number assigned to this event in the event store.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>Number of subscriptions the event was delivered to.</returns>
|
|
Task<int> DeliverEventAsync(
|
|
string correlationId,
|
|
ICorrelatedEvent @event,
|
|
long sequence,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Deliver missed events to a subscription (catch-up).
|
|
/// </summary>
|
|
/// <param name="subscriptionId">The subscription to catch up.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>Number of events delivered during catch-up.</returns>
|
|
Task<int> CatchUpSubscriptionAsync(
|
|
string subscriptionId,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Get pending events for a subscription (not yet delivered).
|
|
/// </summary>
|
|
/// <param name="subscriptionId">The subscription ID.</param>
|
|
/// <param name="limit">Maximum number of events to retrieve.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>List of pending events.</returns>
|
|
Task<IReadOnlyList<ICorrelatedEvent>> GetPendingEventsAsync(
|
|
string subscriptionId,
|
|
int limit = 100,
|
|
CancellationToken cancellationToken = default);
|
|
}
|