Table of Contents

Constructor OutgoingEmailLease

Namespace
MailFathom.Application.Mail.Delivery.Outbox
Assembly
MailFathom.Application.dll

OutgoingEmailLease(Guid, DateTimeOffset)

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

public OutgoingEmailLease(Guid Owner, DateTimeOffset ExpiresAt)

Parameters

Owner Guid

The attempt the lease is held by.

ExpiresAt DateTimeOffset

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

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 a send in flight when a process stops is picked up on its own. The claiming transaction ends with the claim, because the attempt itself reaches a submission server and no transaction may stay open across one.

Two things keep that safe rather than merely likely, and they are the same two the durable job queue rests on. Every write against a leased record is conditional on the owner still matching, so a late writer whose lease was reclaimed writes nothing. And an attempt runs under a timeout strictly shorter than the lease it holds, so it is cancelled before its lease can expire underneath it.

What a lease never does here is release a send whose transmission had begun. The claim reaches records that have issued no SMTP command at all, so a message whose body may already have gone out is not handed to a second attempt by an expiry — the expiry is what makes work recoverable, and that one record is precisely the work that is not.

The owner is a generated identity for the attempt rather than for the process, because two replicas of one deployment are the case the compare-and-set exists for and neither can see what the other allocated. It is not a security token, so the ordinary UUID generator is what it needs.