< 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
77%
Covered lines: 14
Uncovered lines: 4
Coverable lines: 18
Total lines: 86
Line coverage: 77.7%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
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()60%151063.63%

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    /// For multi-replica hosts, enable this only on the selected worker role or partition owner unless the outbox store
 17    /// provides host-owned claim/lease behavior before provider emission.
 18    /// </remarks>
 5219    public bool Enabled { get; set; } = true;
 20
 21    /// <summary>
 22    /// Gets or sets the maximum number of pending or retry-ready entries attempted per drain pass.
 23    /// </summary>
 8224    public int BatchSize { get; set; } = 100;
 25
 26    /// <summary>
 27    /// Gets or sets the interval between drain passes when the worker is enabled.
 28    /// </summary>
 8029    public TimeSpan PollingInterval { get; set; } = TimeSpan.FromSeconds(30);
 30
 31    /// <summary>
 32    /// Gets or sets the delay after an unexpected worker-level failure before the next drain pass is attempted.
 33    /// </summary>
 5234    public TimeSpan FailureDelay { get; set; } = TimeSpan.FromSeconds(30);
 35
 36    /// <summary>
 37    /// Gets or sets the retry clock used when finding retry-ready entries.
 38    /// </summary>
 7639    public Func<DateTimeOffset> RetryClock { get; set; } = static () => DateTimeOffset.UtcNow;
 40
 41    /// <summary>
 42    /// Gets or sets a value indicating whether a final drain pass should be attempted during host shutdown.
 43    /// </summary>
 44    /// <remarks>
 45    /// Avoid enabling shutdown drains on many replicas against the same durable outbox unless duplicate-emission behavi
 46    /// is controlled through partitioning, durable claiming, or provider-side idempotency.
 47    /// </remarks>
 1048    public bool DrainOnShutdown { get; set; }
 49
 50    /// <summary>
 51    /// Gets or sets the maximum amount of time allowed for an optional shutdown drain pass.
 52    /// </summary>
 5853    public TimeSpan ShutdownDrainTimeout { get; set; } = TimeSpan.FromSeconds(5);
 54
 55    /// <summary>
 56    /// Validates the configured worker options.
 57    /// </summary>
 58    /// <exception cref="InvalidOperationException">Thrown when a required worker option is invalid.</exception>
 59    public void Validate()
 60    {
 3261        if (BatchSize <= 0)
 62        {
 463            throw new InvalidOperationException("Governance outbox drain batch size must be greater than zero.");
 64        }
 65
 2866        if (PollingInterval <= TimeSpan.Zero)
 67        {
 068            throw new InvalidOperationException("Governance outbox drain polling interval must be greater than zero.");
 69        }
 70
 2871        if (FailureDelay <= TimeSpan.Zero)
 72        {
 073            throw new InvalidOperationException("Governance outbox drain failure delay must be greater than zero.");
 74        }
 75
 2876        if (ShutdownDrainTimeout <= TimeSpan.Zero)
 77        {
 078            throw new InvalidOperationException("Governance outbox drain shutdown timeout must be greater than zero.");
 79        }
 80
 2881        if (RetryClock is null)
 82        {
 083            throw new InvalidOperationException("Governance outbox drain retry clock must be configured.");
 84        }
 2885    }
 86}