Table of Contents

Method TryAdmitRunAsync

Namespace
MailFathom.Application.Retrieval.AskMail
Assembly
MailFathom.Application.dll

TryAdmitRunAsync(DateTimeOffset, int, long, CancellationToken)

Takes an allowance for one run against the deployment's period, only where both ceilings still have room.

Task<int> TryAdmitRunAsync(DateTimeOffset periodStart, int maximumRuns, long maximumTokens, CancellationToken cancellationToken)

Parameters

periodStart DateTimeOffset

The period's start, as the bounds place it.

maximumRuns int

The greatest number of runs this period may admit.

maximumTokens long

The greatest number of tokens the runs of this period may consume.

cancellationToken CancellationToken

Cancels the admission.

Returns

Task<int>

The runs this period has admitted including this one, or zero where the period is spent.

Remarks

One statement rather than a read and a decision, because every replica admits against the same row: a read-modify-write would let each of them find room the others had already taken. The run is counted by the act of admitting it rather than when it finishes, so a run still in flight already occupies its place.

Exceptions

ArgumentOutOfRangeException

Thrown when either ceiling is below one.