Table of Contents

Class AttachmentDerivationSpendGate

Namespace
MailFathom.Application.Emails.AttachmentText.Limits
Assembly
MailFathom.Application.dll

Answers whether one step of attachment reading may consume right now, and records what it did consume.

public sealed class AttachmentDerivationSpendGate
Inheritance
AttachmentDerivationSpendGate
Inherited Members

Remarks

One type owns both halves for the reason EmbeddingSpendGate does: what a period admits is decided by what the same period has been charged, and splitting the question from the answer would let a reader consult one clock and a writer another.

Two readings exist because two callers ask different questions, and the mailbox's is the one a pass asks. Mail belongs to the account, so a walk holds an account and never a person, while the per-user ceiling still has to mean something: ADR 0014 counts a shared mailbox in full against every user assigned to it, so reading it proceeds only while every one of them is under their ceiling, and what it consumed is charged to each. That fan-out lives here rather than in the pass, so the reading and the charge cannot come to disagree about who a mailbox is for.

The deployment's is the other, and it is what an administrative surface asks: it acts for nobody's mail, so where the deployment stands is the only question it can be answered.

The deployment's figure is not the sum of those per-user charges and is never derived from them. Counting a shared mailbox in full against each of its users is what the per-user ceiling means, so the per-user figures add up to more than was read, and a deployment ceiling taken off their sum would stop a mailbox three people share after a third of what the operator declared. The ledger counts what one reading consumed once, separately.

Constructors

AttachmentDerivationSpendGate(IAttachmentDerivationSpendLedger, IMailAccountAssignments, AttachmentDerivationBudget, TimeProvider)

Initializes a new gate over one deployment's attachment budget.

Methods

ReadCurrentPeriodAsync(AttachmentDerivationStep, CancellationToken)

Reads where the deployment stands on one step, whatever any one user has consumed of it.

ReadCurrentPeriodForAccountAsync(AttachmentDerivationStep, MailAccountId, CancellationToken)

Reads where one mailbox stands on one step, across every user it is assigned to.

RecordAccountSpendAsync(IPersistenceSession, AttachmentDerivationStep, MailAccountId, long, CancellationToken)

Charges what reading one mailbox's message consumed to every user that mailbox is assigned to.