76 lines
2.4 KiB
C#
76 lines
2.4 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Abstractions.Replay;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Replay;
|
|
|
|
/// <summary>
|
|
/// Options for event replay operations.
|
|
/// </summary>
|
|
public class ReplayOptions
|
|
{
|
|
/// <summary>
|
|
/// Maximum number of events to replay (null = unlimited).
|
|
/// Default: null
|
|
/// </summary>
|
|
public long? MaxEvents { get; set; }
|
|
|
|
/// <summary>
|
|
/// Batch size for reading events from storage.
|
|
/// Default: 100
|
|
/// </summary>
|
|
public int BatchSize { get; set; } = 100;
|
|
|
|
/// <summary>
|
|
/// Maximum events per second to replay (null = unlimited).
|
|
/// Useful for rate-limiting to avoid overwhelming consumers.
|
|
/// Default: null (unlimited)
|
|
/// </summary>
|
|
public int? MaxEventsPerSecond { get; set; }
|
|
|
|
/// <summary>
|
|
/// Filter events by type names (null = all types).
|
|
/// Only events with these type names will be replayed.
|
|
/// Default: null
|
|
/// </summary>
|
|
public IReadOnlyList<string>? EventTypeFilter { get; set; }
|
|
|
|
/// <summary>
|
|
/// Include event metadata in replayed events.
|
|
/// Default: true
|
|
/// </summary>
|
|
public bool IncludeMetadata { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Progress callback invoked periodically during replay.
|
|
/// Receives current offset and total events processed.
|
|
/// Default: null
|
|
/// </summary>
|
|
public Action<ReplayProgress>? ProgressCallback { get; set; }
|
|
|
|
/// <summary>
|
|
/// How often to invoke progress callback (in number of events).
|
|
/// Default: 1000
|
|
/// </summary>
|
|
public int ProgressInterval { get; set; } = 1000;
|
|
|
|
/// <summary>
|
|
/// Validates the replay options.
|
|
/// </summary>
|
|
/// <exception cref="ArgumentException">Thrown if options are invalid.</exception>
|
|
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));
|
|
}
|
|
}
|