Table of Contents

Interface IEmbeddingSpendLedger

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

Keeps the durable count of what each budget period has already sent to a provider.

public interface IEmbeddingSpendLedger

Remarks

Durable rather than held in memory, because the failure a spend ceiling exists to prevent is precisely 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 spend the whole ceiling on each attempt.

It is also deliberately not derived from the stored vectors, which would need no table at all. A generation that is superseded has its vectors removed in bounded batches, so a count taken over them would erase the record of a spend that genuinely happened — and the period in which a model change is paid for is exactly the period an operator is watching.

Methods

ReadConsumedInputCharactersAsync(DateTimeOffset, CancellationToken)

Reads what one period has consumed so far.

RecordSpendAsync(IPersistenceSession, DateTimeOffset, long, CancellationToken)

Adds what one provider call sent to the period it belongs to.