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