48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Abstractions.Replay;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Replay;
|
|
|
|
/// <summary>
|
|
/// Progress information for replay operations.
|
|
/// </summary>
|
|
public record ReplayProgress
|
|
{
|
|
/// <summary>
|
|
/// Current offset being processed.
|
|
/// </summary>
|
|
public required long CurrentOffset { get; init; }
|
|
|
|
/// <summary>
|
|
/// Total number of events processed so far.
|
|
/// </summary>
|
|
public required long EventsProcessed { get; init; }
|
|
|
|
/// <summary>
|
|
/// Estimated total events to replay (if known).
|
|
/// </summary>
|
|
public long? EstimatedTotal { get; init; }
|
|
|
|
/// <summary>
|
|
/// Current timestamp of event being processed.
|
|
/// </summary>
|
|
public DateTimeOffset? CurrentTimestamp { get; init; }
|
|
|
|
/// <summary>
|
|
/// Elapsed time since replay started.
|
|
/// </summary>
|
|
public required TimeSpan Elapsed { get; init; }
|
|
|
|
/// <summary>
|
|
/// Events per second processing rate.
|
|
/// </summary>
|
|
public double EventsPerSecond => EventsProcessed / Math.Max(Elapsed.TotalSeconds, 0.001);
|
|
|
|
/// <summary>
|
|
/// Progress percentage (0-100) if total is known.
|
|
/// </summary>
|
|
public double? ProgressPercentage => EstimatedTotal.HasValue && EstimatedTotal.Value > 0
|
|
? (EventsProcessed / (double)EstimatedTotal.Value) * 100
|
|
: null;
|
|
}
|