< Summary

Information
Class: AsiBackbone.AspNetCore.Outbox.AsiBackboneGovernanceOutboxDrainWorkerOptions
Assembly: AsiBackbone.AspNetCore
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/Outbox/AsiBackboneGovernanceOutboxDrainWorkerOptions.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 94
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
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_Enabled()100%11100%
get_BatchSize()100%11100%
get_PollingInterval()100%11100%
get_FailureDelay()100%11100%
get_RetryClock()100%11100%
get_DrainOnShutdown()100%11100%
get_ShutdownDrainTimeout()100%11100%
Validate()100%1010100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/Outbox/AsiBackboneGovernanceOutboxDrainWorkerOptions.cs

#LineLine coverage
 1namespace AsiBackbone.AspNetCore.Outbox;
 2
 3/// <summary>
 4/// Provides host-owned scheduling options for the governance outbox drain worker.
 5/// </summary>
 6/// <remarks>
 7/// The hosted worker is local to the process in which it is registered. In horizontally scaled deployments, each
 8/// replica may run its own worker unless the host disables extra replicas, partitions work, or adds durable claiming.
 9/// </remarks>
 10public sealed class AsiBackboneGovernanceOutboxDrainWorkerOptions
 11{
 12    /// <summary>
 13    /// Gets or sets a value indicating whether the hosted drain worker should run.
 14    /// </summary>
 15    /// <remarks>
 16    /// Runtime changes supplied through <c>IOptionsMonitor</c> pause or resume new drain cycles without restarting the
 17    /// process. A worker that starts disabled remains alive and waits without creating scopes or resolving scoped store
 18    /// Re-enabling normally takes effect immediately through the options change notification, with the configured
 19    /// <see cref="PollingInterval" /> serving as a fallback observation interval.
 20    /// For multi-replica hosts, enable this only on the selected worker role or partition owner unless the outbox store
 21    /// provides host-owned claim/lease behavior before provider emission.
 22    /// </remarks>
 11323    public bool Enabled { get; set; } = true;
 24
 25    /// <summary>
 26    /// Gets or sets the maximum number of pending or retry-ready entries attempted per drain pass.
 27    /// </summary>
 14828    public int BatchSize { get; set; } = 100;
 29
 30    /// <summary>
 31    /// Gets or sets the interval between drain passes when the worker is enabled.
 32    /// </summary>
 33    /// <remarks>
 34    /// While the worker is disabled, this interval is also the fallback check period when the configured options source
 35    /// does not raise a change notification.
 36    /// </remarks>
 15637    public TimeSpan PollingInterval { get; set; } = TimeSpan.FromSeconds(30);
 38
 39    /// <summary>
 40    /// Gets or sets the delay after an unexpected worker-level failure before the next drain pass is attempted.
 41    /// </summary>
 12042    public TimeSpan FailureDelay { get; set; } = TimeSpan.FromSeconds(30);
 43
 44    /// <summary>
 45    /// Gets or sets the retry clock used when finding retry-ready entries.
 46    /// </summary>
 13347    public Func<DateTimeOffset> RetryClock { get; set; } = static () => DateTimeOffset.UtcNow;
 48
 49    /// <summary>
 50    /// Gets or sets a value indicating whether a final drain pass should be attempted during host shutdown.
 51    /// </summary>
 52    /// <remarks>
 53    /// Avoid enabling shutdown drains on many replicas against the same durable outbox unless duplicate-emission behavi
 54    /// is controlled through partitioning, durable claiming, or provider-side idempotency.
 55    /// </remarks>
 2756    public bool DrainOnShutdown { get; set; }
 57
 58    /// <summary>
 59    /// Gets or sets the maximum amount of time allowed for an optional shutdown drain pass.
 60    /// </summary>
 12261    public TimeSpan ShutdownDrainTimeout { get; set; } = TimeSpan.FromSeconds(5);
 62
 63    /// <summary>
 64    /// Validates the configured worker options.
 65    /// </summary>
 66    /// <exception cref="InvalidOperationException">Thrown when a required worker option is invalid.</exception>
 67    public void Validate()
 68    {
 4369        if (BatchSize <= 0)
 70        {
 471            throw new InvalidOperationException("Governance outbox drain batch size must be greater than zero.");
 72        }
 73
 3974        if (PollingInterval <= TimeSpan.Zero)
 75        {
 276            throw new InvalidOperationException("Governance outbox drain polling interval must be greater than zero.");
 77        }
 78
 3779        if (FailureDelay <= TimeSpan.Zero)
 80        {
 281            throw new InvalidOperationException("Governance outbox drain failure delay must be greater than zero.");
 82        }
 83
 3584        if (ShutdownDrainTimeout <= TimeSpan.Zero)
 85        {
 286            throw new InvalidOperationException("Governance outbox drain shutdown timeout must be greater than zero.");
 87        }
 88
 3389        if (RetryClock is null)
 90        {
 191            throw new InvalidOperationException("Governance outbox drain retry clock must be configured.");
 92        }
 3293    }
 94}