| | | 1 | | namespace AsyncResponse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// The execution lease a store has persisted for one flow ledger, exactly as stored: who holds it |
| | | 5 | | /// and until when. Returned by <see cref="IFlowStateStore.ObserveLeaseAsync"/>. |
| | | 6 | | /// <para> |
| | | 7 | | /// The engine never judges <see cref="ExpiresAtUtc"/> against its own clock to decide ownership — |
| | | 8 | | /// that stays the store's job in <see cref="IFlowStateStore.TryAcquireLeaseAsync"/>. It compares |
| | | 9 | | /// two observations of the same ledger with each other: a different <see cref="LeaseId"/>, or a |
| | | 10 | | /// later <see cref="ExpiresAtUtc"/> under the same id, can only have been written by a worker that |
| | | 11 | | /// acquired or renewed the lease in between, which is the proof of a live holder that a waiter's |
| | | 12 | | /// own lease configuration cannot give. |
| | | 13 | | /// </para> |
| | | 14 | | /// </summary> |
| | | 15 | | public sealed class FlowLeaseObservation |
| | | 16 | | { |
| | | 17 | | /// <summary>The observation of a ledger nobody holds (never leased, released, or absent).</summary> |
| | 224 | 18 | | public static FlowLeaseObservation Unheld { get; } = new(null, null); |
| | | 19 | | |
| | | 20 | | /// <param name="leaseId">The persisted lease owner, or <c>null</c> when no lease is held.</param> |
| | | 21 | | /// <param name="expiresAtUtc">The persisted lease expiry, or <c>null</c> when no lease is held.</param> |
| | 771 | 22 | | public FlowLeaseObservation(string? leaseId, DateTime? expiresAtUtc) |
| | | 23 | | { |
| | 771 | 24 | | LeaseId = leaseId; |
| | 771 | 25 | | ExpiresAtUtc = expiresAtUtc; |
| | 771 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary>The persisted lease owner; <c>null</c> when no lease is held.</summary> |
| | 12865 | 29 | | public string? LeaseId { get; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The persisted lease expiry (UTC), possibly already in the past — an expired lease stays on |
| | | 33 | | /// the row until someone acquires or releases it. <c>null</c> when no lease is held. |
| | | 34 | | /// </summary> |
| | 8906 | 35 | | public DateTime? ExpiresAtUtc { get; } |
| | | 36 | | } |