using System;
using Svrnty.CQRS.Events.Abstractions.Replay;
using System.Collections.Generic;
namespace Svrnty.CQRS.Events.Abstractions.Replay;
///
/// Options for event replay operations.
///
public class ReplayOptions
{
///
/// Maximum number of events to replay (null = unlimited).
/// Default: null
///
public long? MaxEvents { get; set; }
///
/// Batch size for reading events from storage.
/// Default: 100
///
public int BatchSize { get; set; } = 100;
///
/// Maximum events per second to replay (null = unlimited).
/// Useful for rate-limiting to avoid overwhelming consumers.
/// Default: null (unlimited)
///
public int? MaxEventsPerSecond { get; set; }
///
/// Filter events by type names (null = all types).
/// Only events with these type names will be replayed.
/// Default: null
///
public IReadOnlyList? EventTypeFilter { get; set; }
///
/// Include event metadata in replayed events.
/// Default: true
///
public bool IncludeMetadata { get; set; } = true;
///
/// Progress callback invoked periodically during replay.
/// Receives current offset and total events processed.
/// Default: null
///
public Action? ProgressCallback { get; set; }
///
/// How often to invoke progress callback (in number of events).
/// Default: 1000
///
public int ProgressInterval { get; set; } = 1000;
///
/// Validates the replay options.
///
/// Thrown if options are invalid.
public void Validate()
{
if (BatchSize <= 0)
throw new ArgumentException("BatchSize must be positive", nameof(BatchSize));
if (MaxEvents.HasValue && MaxEvents.Value <= 0)
throw new ArgumentException("MaxEvents must be positive", nameof(MaxEvents));
if (MaxEventsPerSecond.HasValue && MaxEventsPerSecond.Value <= 0)
throw new ArgumentException("MaxEventsPerSecond must be positive", nameof(MaxEventsPerSecond));
if (ProgressInterval <= 0)
throw new ArgumentException("ProgressInterval must be positive", nameof(ProgressInterval));
}
}