Table of Contents

Class JobLease

Namespace
MailFathom.Application.Jobs
Assembly
MailFathom.Application.dll

Holds one job for one attempt, until an instant rather than until somebody lets go.

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

Remarks

A lease is a stamped row rather than a flag, which is what makes a crash recoverable without anything being told a process died: an expired lease is claimable again, so work in flight when a process stops is picked up 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.

Two things keep that safe rather than merely likely. Every write against a leased job is conditional on the owner still matching, so a late writer whose lease was reclaimed writes nothing. And the timeout an attempt runs under is strictly shorter than the lease it holds, so an attempt is cancelled before its lease can expire underneath it — which is what makes two workers running one job structurally impossible rather than rare.

Constructors

JobLease(JobLeaseOwner, DateTimeOffset)

Holds one job for one attempt, until an instant rather than until somebody lets go.

Properties

ExpiresAt

The instant after which the job is claimable again whatever the holder is doing.

Owner

The attempt the lease is held by.

Methods

HasExpiredAt(DateTimeOffset)

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

IsHeldBy(JobLeaseOwner)

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