Interface IMailAnsweringSpendPeriodStore
- Namespace
- MailFathom.Application.Retrieval.AskMail
- Assembly
- MailFathom.Application.dll
Keeps the durable count of what each answering period has admitted and consumed, for the whole deployment.
public interface IMailAnsweringSpendPeriodStore
Remarks
Durable rather than held in memory, because a ceiling worded as the deployment's is overshot by the replica count when each process counts its own: three replicas each admitting thirty runs an hour admit ninety, at a provider the operator is billed by. ADR 0031 records the trade this reverses: a write per provider call was refused and a write per admitted run was not, because a run is already about to spend a provider's tokens and one row touched beside that is not measurable.
Nothing allocates a period. Its start is where the bounds place the current instant, so every replica derives the same key from its own clock, the first run of a period inserts its row, and a period nobody asked a question in has no row at all.
Both members answer with the period's own figure after the write, because that is the reading an operator's instruments publish and it costs nothing beside a write that was going to happen. Neither is a query: what has been spent is not a question any use case above this asks.
Methods
- RecordSpendAsync(DateTimeOffset, long, CancellationToken)
Adds what one run consumed to the period it ended in.
- TryAdmitRunAsync(DateTimeOffset, int, long, CancellationToken)
Takes an allowance for one run against the deployment's period, only where both ceilings still have room.