65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using System;
|
|
|
|
namespace Svrnty.CQRS.Events.Delivery;
|
|
|
|
/// <summary>
|
|
/// Configuration options for exactly-once delivery semantics.
|
|
/// </summary>
|
|
public class ExactlyOnceDeliveryOptions
|
|
{
|
|
/// <summary>
|
|
/// Duration for which an idempotency lock is held during event processing.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Default: 30 seconds
|
|
/// </para>
|
|
/// <para>
|
|
/// This should be long enough for typical event processing but short enough
|
|
/// to prevent long delays if a process crashes while holding a lock.
|
|
/// </para>
|
|
/// </remarks>
|
|
public TimeSpan LockDuration { get; set; } = TimeSpan.FromSeconds(30);
|
|
|
|
/// <summary>
|
|
/// Maximum number of retry attempts when failing to acquire an idempotency lock.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Default: 3 retries
|
|
/// </para>
|
|
/// <para>
|
|
/// Set to 0 to fail immediately without retries.
|
|
/// After max retries, the event is skipped (assumed to be processed by another instance).
|
|
/// </para>
|
|
/// </remarks>
|
|
public int MaxRetries { get; set; } = 3;
|
|
|
|
/// <summary>
|
|
/// Delay between retry attempts when lock acquisition fails.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Default: 100 milliseconds
|
|
/// </para>
|
|
/// <para>
|
|
/// Use exponential backoff by multiplying this value by the retry count if needed.
|
|
/// </para>
|
|
/// </remarks>
|
|
public TimeSpan RetryDelay { get; set; } = TimeSpan.FromMilliseconds(100);
|
|
|
|
/// <summary>
|
|
/// Whether to use exponential backoff for retries.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Default: false
|
|
/// </para>
|
|
/// <para>
|
|
/// When enabled, retry delay = RetryDelay * 2^retryCount
|
|
/// Example: 100ms, 200ms, 400ms, 800ms...
|
|
/// </para>
|
|
/// </remarks>
|
|
public bool UseExponentialBackoff { get; set; } = false;
|
|
}
|