< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%22100%
get_Entry()100%11100%
get_OutboxEntryId()100%11100%
get_WorkerId()100%11100%
get_ClaimToken()100%11100%
get_ClaimedUtc()100%11100%
get_ClaimExpiresUtc()100%11100%
IsExpired(...)100%11100%
Create(...)100%11100%

File(s)

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

#LineLine coverage
 1namespace AsiBackbone.Core.Outbox;
 2
 3/// <summary>
 4/// Represents a successful claim over a governance outbox entry.
 5/// </summary>
 6/// <remarks>
 7/// A claim proves that a worker acquired a lease before provider emission. It reduces duplicate selection risk for coop
 8/// </remarks>
 9public sealed class GovernanceOutboxClaim
 10{
 51011    private GovernanceOutboxClaim(
 51012        GovernanceOutboxEntry entry,
 51013        string workerId,
 51014        string claimToken,
 51015        DateTimeOffset claimedUtc,
 51016        DateTimeOffset claimExpiresUtc)
 17    {
 51018        ArgumentNullException.ThrowIfNull(entry);
 51019        ArgumentException.ThrowIfNullOrWhiteSpace(workerId);
 51020        ArgumentException.ThrowIfNullOrWhiteSpace(claimToken);
 21
 51022        if (claimExpiresUtc.ToUniversalTime() <= claimedUtc.ToUniversalTime())
 23        {
 424            throw new ArgumentOutOfRangeException(nameof(claimExpiresUtc), claimExpiresUtc, "Claim expiration must be af
 25        }
 26
 50627        Entry = entry;
 50628        WorkerId = workerId.Trim();
 50629        ClaimToken = claimToken.Trim();
 50630        ClaimedUtc = claimedUtc.ToUniversalTime();
 50631        ClaimExpiresUtc = claimExpiresUtc.ToUniversalTime();
 50632    }
 33
 34    /// <summary>
 35    /// Gets the claimed outbox entry snapshot.
 36    /// </summary>
 114837    public GovernanceOutboxEntry Entry { get; }
 38
 39    /// <summary>
 40    /// Gets the stable outbox entry identifier.
 41    /// </summary>
 72842    public string OutboxEntryId => Entry.OutboxEntryId;
 43
 44    /// <summary>
 45    /// Gets the worker, process, node, or partition owner that acquired the claim.
 46    /// </summary>
 49647    public string WorkerId { get; }
 48
 49    /// <summary>
 50    /// Gets the opaque token that identifies this lease instance.
 51    /// </summary>
 45652    public string ClaimToken { get; }
 53
 54    /// <summary>
 55    /// Gets the UTC timestamp when the claim was acquired.
 56    /// </summary>
 35057    public DateTimeOffset ClaimedUtc { get; }
 58
 59    /// <summary>
 60    /// Gets the UTC timestamp when the claim lease expires.
 61    /// </summary>
 36062    public DateTimeOffset ClaimExpiresUtc { get; }
 63
 64    /// <summary>
 65    /// Determines whether the claim lease is expired at the supplied UTC timestamp.
 66    /// </summary>
 67    public bool IsExpired(DateTimeOffset utcNow)
 68    {
 1069        return ClaimExpiresUtc <= utcNow.ToUniversalTime();
 70    }
 71
 72    /// <summary>
 73    /// Creates a claim from a claimed entry snapshot.
 74    /// </summary>
 75    public static GovernanceOutboxClaim Create(
 76        GovernanceOutboxEntry entry,
 77        string workerId,
 78        string claimToken,
 79        DateTimeOffset claimedUtc,
 80        DateTimeOffset claimExpiresUtc)
 81    {
 51082        return new GovernanceOutboxClaim(entry, workerId, claimToken, claimedUtc, claimExpiresUtc);
 83    }
 84}