Interface IAttachmentDerivationSpendLedger
- Namespace
- MailFathom.Application.Emails.AttachmentText.Limits
- Assembly
- MailFathom.Application.dll
Keeps the durable count of what each budget period has consumed reading attachments, per step and per user.
public interface IAttachmentDerivationSpendLedger
Remarks
Durable rather than held in memory, for the reason the embedding ledger is: the failure an aggregate ceiling exists to prevent is exactly the one an in-process counter cannot see. A process that crashes and restarts in a loop would begin every period again from zero and read the whole ceiling's worth of attachments on each attempt.
Kept apart from the stored readings, which would need no table at all. A reading discarded by a re-derivation, by a junk verdict, or by a user's erasure would take the record of a parse that genuinely happened with it — and the period in which a large mailbox is first read is exactly the period an operator is watching.
Every charge names the step it belongs to, because the two are counted in units that do not convert, and the users it was incurred for, because a deployment serving several people bounds each of them as well as itself. What the deployment consumed is counted separately from them rather than summed out of them, for the reason the embedding ledger's is: ADR 0014 counts a shared mailbox in full against each of its users, so the per-user figures add up to more than was read and a deployment ceiling taken off their sum would stop a shared mailbox at a fraction of what an operator declared. That same ADR keeps a spend row as a cost record rather than erasing it with the mail it paid to read.
Methods
- ReadConsumedAsync(DateTimeOffset, AttachmentDerivationStep, UserId, CancellationToken)
Reads what one period has consumed on one step, for one user and for the deployment.
- ReadDeploymentConsumedAsync(DateTimeOffset, AttachmentDerivationStep, CancellationToken)
Reads what one period actually consumed on one step, whoever it was counted against.
- RecordSpendAsync(IPersistenceSession, DateTimeOffset, AttachmentDerivationStep, IReadOnlyCollection<UserId>, long, CancellationToken)
Adds what reading one message consumed, once to the period and in full to each user it is charged to.