< Summary

Information
Class: AsiBackbone.Core.Outbox.AsiBackboneGovernanceOutboxOptions
Assembly: AsiBackbone.Core
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/Outbox/AsiBackboneGovernanceOutboxOptions.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 111
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_RetryDelay()100%11100%
get_DeferredDelay()100%11100%
get_MaxRetryAttempts()100%11100%
get_DeadLetterOnMaxRetryAttempts()100%11100%
get_DeadLetterReasonCode()100%11100%
get_DeadLetterReasonMessage()100%11100%
get_UseClaimLeases()100%11100%
get_ClaimWorkerId()100%11100%
get_ClaimLeaseDuration()100%11100%
Validate()100%1212100%
ValidateDelay(...)100%22100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/Outbox/AsiBackboneGovernanceOutboxOptions.cs

#LineLine coverage
 1namespace AsiBackbone.Core.Outbox;
 2
 3/// <summary>
 4/// Provides provider-neutral retry timing, poison-message, and optional claim/lease options for governance outbox drain
 5/// </summary>
 6/// <remarks>
 7/// These options control default retry timestamps when a downstream emitter does not provide its own retry-after value.
 8/// </remarks>
 9public sealed class AsiBackboneGovernanceOutboxOptions
 10{
 11    /// <summary>
 12    /// Gets the stable default reason code used when the drain dead-letters an entry after the configured retry thresho
 13    /// </summary>
 14    public const string DefaultDeadLetterReasonCode = "outbox.max_retry_attempts_exceeded";
 15
 16    /// <summary>
 17    /// Gets the stable default reason message used when the drain dead-letters an entry after the configured retry thre
 18    /// </summary>
 19    public const string DefaultDeadLetterReasonMessage = "Governance outbox entry exceeded the configured maximum retry 
 20
 21    /// <summary>
 22    /// Gets or sets the default delay applied after a transient emission failure or unexpected emitter exception.
 23    /// </summary>
 63624    public TimeSpan RetryDelay { get; set; } = TimeSpan.FromMinutes(1);
 25
 26    /// <summary>
 27    /// Gets or sets the default delay applied when an emitter returns a pending or deferred result without a retry-afte
 28    /// </summary>
 63129    public TimeSpan DeferredDelay { get; set; } = TimeSpan.FromMinutes(1);
 30
 31    /// <summary>
 32    /// Gets or sets the maximum number of failed emission attempts permitted before the drain applies its poison-messag
 33    /// </summary>
 34    /// <remarks>
 35    /// The threshold counts the failure currently being processed. A value of <c>1</c> dead-letters the first failed at
 36    /// </remarks>
 65037    public int MaxRetryAttempts { get; set; } = 5;
 38
 39    /// <summary>
 40    /// Gets or sets a value indicating whether entries are dead-lettered when <see cref="MaxRetryAttempts" /> is reache
 41    /// </summary>
 50742    public bool DeadLetterOnMaxRetryAttempts { get; set; } = true;
 43
 44    /// <summary>
 45    /// Gets or sets the provider-neutral reason code recorded when the configured retry threshold is reached.
 46    /// </summary>
 60947    public string DeadLetterReasonCode { get; set; } = DefaultDeadLetterReasonCode;
 48
 49    /// <summary>
 50    /// Gets or sets the provider-neutral reason message recorded when the configured retry threshold is reached.
 51    /// </summary>
 61152    public string DeadLetterReasonMessage { get; set; } = DefaultDeadLetterReasonMessage;
 53
 54    /// <summary>
 55    /// Gets or sets a value indicating whether the drain should claim outbox entries before provider emission when the 
 56    /// </summary>
 50157    public bool UseClaimLeases { get; set; }
 58
 59    /// <summary>
 60    /// Gets or sets the worker, process, node, or partition identifier used when <see cref="UseClaimLeases" /> is enabl
 61    /// </summary>
 39462    public string? ClaimWorkerId { get; set; }
 63
 64    /// <summary>
 65    /// Gets or sets the lease duration used when <see cref="UseClaimLeases" /> is enabled.
 66    /// </summary>
 71167    public TimeSpan ClaimLeaseDuration { get; set; } = GovernanceOutboxClaimRequest.DefaultLeaseDuration;
 68
 69    /// <summary>
 70    /// Validates the configured outbox retry, poison-message, timing, and claim options.
 71    /// </summary>
 72    /// <exception cref="InvalidOperationException">Thrown when a retry threshold, reason, delay, or claim lease option 
 73    public void Validate()
 74    {
 14575        ValidateDelay(RetryDelay, nameof(RetryDelay));
 13976        ValidateDelay(DeferredDelay, nameof(DeferredDelay));
 77
 13378        if (MaxRetryAttempts <= 0)
 79        {
 280            throw new InvalidOperationException($"{nameof(MaxRetryAttempts)} must be greater than zero.");
 81        }
 82
 13183        if (string.IsNullOrWhiteSpace(DeadLetterReasonCode))
 84        {
 285            throw new InvalidOperationException($"{nameof(DeadLetterReasonCode)} is required.");
 86        }
 87
 12988        if (string.IsNullOrWhiteSpace(DeadLetterReasonMessage))
 89        {
 290            throw new InvalidOperationException($"{nameof(DeadLetterReasonMessage)} is required.");
 91        }
 92
 12793        if (ClaimLeaseDuration <= TimeSpan.Zero)
 94        {
 495            throw new InvalidOperationException($"{nameof(ClaimLeaseDuration)} must be greater than TimeSpan.Zero.");
 96        }
 97
 12398        if (UseClaimLeases && string.IsNullOrWhiteSpace(ClaimWorkerId))
 99        {
 4100            throw new InvalidOperationException($"{nameof(ClaimWorkerId)} is required when {nameof(UseClaimLeases)} is e
 101        }
 119102    }
 103
 104    private static void ValidateDelay(TimeSpan delay, string propertyName)
 105    {
 284106        if (delay < TimeSpan.Zero)
 107        {
 12108            throw new InvalidOperationException($"{propertyName} must be greater than or equal to TimeSpan.Zero.");
 109        }
 272110    }
 111}