Class RateLimitOptions
- Namespace
- Kevlar
- Assembly
- Kevlar.dll
Configuration for a token-bucket rate limit strategy: Permits executions per Window, with bursts up to Burst and optional queueing.
public sealed class RateLimitOptions
- Inheritance
-
RateLimitOptions
- Inherited Members
Remarks
When an execution is rejected, rejection metrics are recorded and OnRejected runs and is awaited. Callback failures are reported through OnCallbackError and do not replace the rejection.
Constructors
RateLimitOptions()
public RateLimitOptions()
Properties
Burst
Maximum permits that can accumulate for bursting. Defaults to Permits.
public int? Burst { get; set; }
Property Value
- int?
Name
An optional low-cardinality name used by strategy telemetry.
public string? Name { get; set; }
Property Value
OnRejected
Invoked and awaited when an execution is rejected. Return default from a synchronous callback.
public Func<RateLimitRejectedEvent, ValueTask>? OnRejected { get; set; }
Property Value
Permits
Sustained number of executions allowed per Window. Default 100.
public int Permits { get; set; }
Property Value
QueueLimit
How many executions may wait for a permit instead of being rejected immediately. Waiting executions are delayed until their reserved permit is replenished. Default 0.
public int QueueLimit { get; set; }
Property Value
QueueTimeout
Maximum time spent waiting in the queue. Null (the default) leaves the wait unbounded. Must be positive and at most 4,294,967,294 milliseconds when configured. This limit ends when execution is admitted and does not bound execution time.
public TimeSpan? QueueTimeout { get; set; }
Property Value
UsePriorityQueue
Enables highest-priority-first queue admission using KevlarKeys.Priority, with FIFO ties. Unset priorities are zero. A higher-priority arrival evicts the newest lowest-priority waiter when the queue is full. Default false preserves the ordinary queue behavior.
public bool UsePriorityQueue { get; set; }
Property Value
Window
The time window over which Permits are replenished. Default 1 second.
public TimeSpan Window { get; set; }