Class FailureBudget<TKey>
A token budget for each key, billed only after a failure is observed, refilling at one token per Period up to Burst.
public sealed class FailureBudget<TKey> where TKey : notnull
Type Parameters
TKey
- Inheritance
-
FailureBudget<TKey>
- Inherited Members
Remarks
System.Threading.RateLimiting can't do this: its leases are acquired before the outcome is known. A balance can go negative, in which case in-flight failures must be drained before the key is allowed again.
Constructors
FailureBudget(RateLimit)
A token budget for each key, billed only after a failure is observed, refilling at one token per Period up to Burst.
public FailureBudget(RateLimit limit)
Parameters
limitRateLimit
Remarks
System.Threading.RateLimiting can't do this: its leases are acquired before the outcome is known. A balance can go negative, in which case in-flight failures must be drained before the key is allowed again.
Methods
Charge(TKey)
Bill one failure to the key.
public void Charge(TKey key)
Parameters
keyTKey
IsAllowed(TKey)
True if the key has not exhausted its budget.
public bool IsAllowed(TKey key)
Parameters
keyTKey