Table of Contents

Class WorkLease

Namespace
MailFathom.Application.Coordination
Assembly
MailFathom.Application.dll

Holds one scope for one holder, until an instant rather than until somebody lets go.

public sealed record WorkLease : IEquatable<WorkLease>
Inheritance
WorkLease
Implements
Inherited Members

Remarks

A lease is a stamped row rather than a flag, which is what makes a lost replica recoverable without anything being told it died: an expired lease is takeable, so a scope a crashed process was holding is taken again on its own. The claiming transaction ends with the claim, because the work itself reaches a mail server or a model provider and no transaction may stay open across one.

What it promises is one writer, never one runner. Every write against a leased scope is conditional on the holder still matching, so a replica whose lease was reclaimed commits nothing; what is not excluded is that it is still running, and what bounds that is the holder cancelling its own work on the first renewal it fails to complete rather than when the expiry it last read has passed. A failed renewal happens strictly before the expiry, and the difference is the margin that leaves the cancellation time to reach a session rather than only a loop.

The replica is carried beside the holder and is never compared with anything. The holder is what makes a write from a hold that moved write nothing; the replica is what makes the row readable — an operator asking who holds an account is told a process they can find a log for rather than a generated hold identity that names nothing.

Constructors

WorkLease(WorkScope, WorkLeaseHolder, ReplicaIdentity, DateTimeOffset)

Holds one scope for one holder, until an instant rather than until somebody lets go.

Properties

ExpiresAt

The instant after which the scope is takeable again whatever the holder is doing.

Holder

The hold the lease is held under.

Replica

The replica the hold belongs to, which is what an operator reads to find the process the work is happening in.

Scope

The unit of work the lease holds.

Methods

HasExpiredAt(DateTimeOffset)

Reports whether the lease has run out by a given instant.

IsHeldBy(WorkLeaseHolder)

Reports whether a given hold is the one holding this lease.