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;
///
/// Service responsible for delivering events to persistent subscriptions.
///
public interface IPersistentSubscriptionDeliveryService
{
///
/// Deliver an event to all matching subscriptions for a correlation ID.
///
/// The correlation ID to match subscriptions against.
/// The event to deliver.
/// The sequence number assigned to this event in the event store.
/// Cancellation token.
/// Number of subscriptions the event was delivered to.
Task DeliverEventAsync(
string correlationId,
ICorrelatedEvent @event,
long sequence,
CancellationToken cancellationToken = default);
///
/// Deliver missed events to a subscription (catch-up).
///
/// The subscription to catch up.
/// Cancellation token.
/// Number of events delivered during catch-up.
Task CatchUpSubscriptionAsync(
string subscriptionId,
CancellationToken cancellationToken = default);
///
/// Get pending events for a subscription (not yet delivered).
///
/// The subscription ID.
/// Maximum number of events to retrieve.
/// Cancellation token.
/// List of pending events.
Task> GetPendingEventsAsync(
string subscriptionId,
int limit = 100,
CancellationToken cancellationToken = default);
}