using System; using Svrnty.CQRS.Events.Abstractions.Replay; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Svrnty.CQRS.Events.Abstractions.Models; namespace Svrnty.CQRS.Events.Abstractions.Replay; /// /// Service for replaying historical events from persistent streams. /// Enables rebuilding projections, reprocessing events, and time-travel debugging. /// public interface IEventReplayService { /// /// Replay events from a specific offset. /// /// Stream to replay from. /// Starting offset (inclusive). /// Replay options. /// Cancellation token. /// Async enumerable of events. /// /// Events are returned in offset order (oldest first). /// Use ReplayOptions to control batch size, rate limiting, and filtering. /// IAsyncEnumerable ReplayFromOffsetAsync( string streamName, long startOffset, ReplayOptions? options = null, CancellationToken cancellationToken = default); /// /// Replay events from a specific timestamp. /// /// Stream to replay from. /// Starting timestamp (UTC, inclusive). /// Replay options. /// Cancellation token. /// Async enumerable of events. /// /// Finds the first event at or after the specified timestamp. /// All subsequent events are returned in order. /// IAsyncEnumerable ReplayFromTimeAsync( string streamName, DateTimeOffset startTime, ReplayOptions? options = null, CancellationToken cancellationToken = default); /// /// Replay events within a time range. /// /// Stream to replay from. /// Starting timestamp (UTC, inclusive). /// Ending timestamp (UTC, exclusive). /// Replay options. /// Cancellation token. /// Async enumerable of events. /// /// Only events with stored_at >= startTime AND stored_at < endTime are returned. /// Useful for replaying specific time periods. /// IAsyncEnumerable ReplayTimeRangeAsync( string streamName, DateTimeOffset startTime, DateTimeOffset endTime, ReplayOptions? options = null, CancellationToken cancellationToken = default); /// /// Replay all events in a stream from the beginning. /// /// Stream to replay from. /// Replay options. /// Cancellation token. /// Async enumerable of events. /// /// Equivalent to ReplayFromOffsetAsync(streamName, 0, options). /// Use for complete stream replay when rebuilding projections. /// IAsyncEnumerable ReplayAllAsync( string streamName, ReplayOptions? options = null, CancellationToken cancellationToken = default); /// /// Get the total count of events that would be replayed. /// /// Stream to count events for. /// Starting offset (optional). /// Starting timestamp (optional). /// Ending timestamp (optional). /// Replay options (for event type filtering). /// Cancellation token. /// Count of events matching the criteria. /// /// Useful for estimating replay duration and showing progress. /// Counts only events matching the event type filter if specified. /// Task GetReplayCountAsync( string streamName, long? startOffset = null, DateTimeOffset? startTime = null, DateTimeOffset? endTime = null, ReplayOptions? options = null, CancellationToken cancellationToken = default); }