Table of Contents

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

session IPersistenceSession

The session whose transaction this write joins.

periodStart DateTimeOffset

The period's start, as the budget places it.

inputCharacterCount long

The characters the call sent.

cancellationToken CancellationToken

Propagates 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 session is null.

ArgumentOutOfRangeException

Thrown when the count is negative.