< 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: 20
Uncovered lines: 0
Coverable lines: 20
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_OutboxEntryId()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 an 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{
 39611    private GovernanceOutboxClaim(
 39612        GovernanceOutboxEntry entry,
 39613        string workerId,
 39614        string claimToken,
 39615        DateTimeOffset claimedUtc,
 39616        DateTimeOffset claimExpiresUtc)
 17    {
 39618        ArgumentNullException.ThrowIfNull(entry);
 39619        ArgumentException.ThrowIfNullOrWhiteSpace(workerId);
 39620        ArgumentException.ThrowIfNullOrWhiteSpace(claimToken);
 21
 39622        if (claimExpiresUtc.ToUniversalTime() <= claimedUtc.ToUniversalTime())
 23        {
 224            throw new ArgumentOutOfRangeException(nameof(claimExpiresUtc), claimExpiresUtc, "Claim expiration must be af
 25        }
 26
 39427        Entry = entry;
 39428        WorkerId = workerId.Trim();
 39429        ClaimToken = claimToken.Trim();
 39430        ClaimedUtc = claimedUtc.ToUniversalTime();
 39431        ClaimExpiresUtc = claimExpiresUtc.ToUniversalTime();
 39432    }
 33
 34    /// <summary>
 35    /// Gets the claimed outbox entry snapshot.
 36    /// </summary>
 37    public GovernanceOutboxEntry Entry { get; }
 38
 39    /// <summary>
 40    /// Gets the stable outbox entry identifier.
 41    /// </summary>
 43642    public string OutboxEntryId => Entry.OutboxEntryId;
 43
 44    /// <summary>
 45    /// Gets the worker, process, node, or partition owner that acquired the claim.
 46    /// </summary>
 47    public string WorkerId { get; }
 48
 49    /// <summary>
 50    /// Gets the opaque token that identifies this lease instance.
 51    /// </summary>
 52    public string ClaimToken { get; }
 53
 54    /// <summary>
 55    /// Gets the UTC timestamp when the claim was acquired.
 56    /// </summary>
 57    public DateTimeOffset ClaimedUtc { get; }
 58
 59    /// <summary>
 60    /// Gets the UTC timestamp when the claim lease expires.
 61    /// </summary>
 62    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    {
 569        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    {
 39682        return new GovernanceOutboxClaim(entry, workerId, claimToken, claimedUtc, claimExpiresUtc);
 83    }
 84}