< Summary

Information
Class: AsiBackbone.Core.Outbox.GovernanceOutboxClaimRequest
Assembly: AsiBackbone.Core
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/Outbox/GovernanceOutboxClaimRequest.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 80
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor(...)100%44100%
get_ClaimExpiresUtc()100%11100%
Create(...)100%44100%

File(s)

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

#LineLine coverage
 1namespace AsiBackbone.Core.Outbox;
 2
 3/// <summary>
 4/// Describes an opt-in outbox claim and lease request.
 5/// </summary>
 6/// <remarks>
 7/// Claim requests are used by claim-capable stores to coordinate scaled workers before provider emission. They do not c
 8/// </remarks>
 9public sealed class GovernanceOutboxClaimRequest
 10{
 11    /// <summary>
 12    /// Gets the default lease duration for claimed outbox work.
 13    /// </summary>
 314    public static readonly TimeSpan DefaultLeaseDuration = TimeSpan.FromMinutes(5);
 15
 14516    private GovernanceOutboxClaimRequest(
 14517        string workerId,
 14518        DateTimeOffset utcNow,
 14519        TimeSpan leaseDuration,
 14520        int maxCount)
 21    {
 14522        ArgumentException.ThrowIfNullOrWhiteSpace(workerId);
 23
 14424        if (leaseDuration <= TimeSpan.Zero)
 25        {
 226            throw new ArgumentOutOfRangeException(nameof(leaseDuration), leaseDuration, "Lease duration must be greater 
 27        }
 28
 14229        if (maxCount <= 0)
 30        {
 231            throw new ArgumentOutOfRangeException(nameof(maxCount), maxCount, "Maximum count must be greater than zero."
 32        }
 33
 14034        WorkerId = workerId.Trim();
 14035        UtcNow = utcNow.ToUniversalTime();
 14036        LeaseDuration = leaseDuration;
 14037        MaxCount = maxCount;
 14038    }
 39
 40    /// <summary>
 41    /// Gets the stable worker, process, node, or partition owner identifier requesting the claim.
 42    /// </summary>
 43    public string WorkerId { get; }
 44
 45    /// <summary>
 46    /// Gets the UTC timestamp used for eligibility and lease expiration calculations.
 47    /// </summary>
 48    public DateTimeOffset UtcNow { get; }
 49
 50    /// <summary>
 51    /// Gets the requested claim lease duration.
 52    /// </summary>
 53    public TimeSpan LeaseDuration { get; }
 54
 55    /// <summary>
 56    /// Gets the maximum number of entries to claim.
 57    /// </summary>
 58    public int MaxCount { get; }
 59
 60    /// <summary>
 61    /// Gets the UTC timestamp at which the requested lease expires.
 62    /// </summary>
 4563    public DateTimeOffset ClaimExpiresUtc => UtcNow.Add(LeaseDuration);
 64
 65    /// <summary>
 66    /// Creates a claim request with normalized worker and timing values.
 67    /// </summary>
 68    public static GovernanceOutboxClaimRequest Create(
 69        string workerId,
 70        DateTimeOffset? utcNow = null,
 71        TimeSpan? leaseDuration = null,
 72        int maxCount = 100)
 73    {
 14574        return new GovernanceOutboxClaimRequest(
 14575            workerId,
 14576            utcNow ?? DateTimeOffset.UtcNow,
 14577            leaseDuration ?? DefaultLeaseDuration,
 14578            maxCount);
 79    }
 80}