Method RecordSpendAsync
- Namespace
- MailFathom.Application.Emails.Embeddings.Limits
- Assembly
- MailFathom.Application.dll
RecordSpendAsync(IPersistenceSession, DateTimeOffset, long, CancellationToken)
Adds what one provider call sent to the period it belongs to.
Task RecordSpendAsync(IPersistenceSession session, DateTimeOffset periodStart, long inputCharacterCount, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe session whose transaction this write joins.
periodStartDateTimeOffsetThe period's start, as the budget places it.
inputCharacterCountlongThe characters the call sent.
cancellationTokenCancellationTokenPropagates caller cancellation.
Returns
- Task
A task that completes when the increment has been issued inside the caller's transaction.
Remarks
Written inside the transaction that commits the vectors the call produced, so the two are one durable fact: a crash between them cannot leave vectors nothing was charged for, or a charge for vectors that were never stored. The increment is expressed as an increment rather than as a read followed by a write, so two workers spending against one period add to each other instead of overwriting one another's total.
Exceptions
- ArgumentNullException
Thrown when
sessionis null.- ArgumentOutOfRangeException
Thrown when the count is negative.