Class KeyedThrottleProcessor
Throttle per key: each distinct key (customer id, tenant, API key…) gets its own sliding-window gate,
and the limit is read from the message, so key and limit can come from the exchange
("gold customers 100 per second, others 10, each under its own key").
A key's gate is a — the same arrival-order-fair,
per-message-limit gate as the plain Throttle, one per key — so both throttles behave
identically, including the two overflow modes (wait, or reject with 429 + Retry-After).
Gates idle for two periods are evicted, at most once per period, so a high-cardinality key space
neither grows without bound nor is scanned on every message.
public sealed class KeyedThrottleProcessor : IProcessor, IDisposable
Inheritance
Implements
Properties
ActiveKeyCount
Number of keys currently holding a gate (diagnostics / tests).
public int ActiveKeyCount { get; }
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Process(IExchange, CancellationToken)
Processes the exchange asynchronously.
public Task Process(IExchange exchange, CancellationToken ct = default)
Constructors
KeyedThrottleProcessor(IProcessor, Func<IExchange, string>, Func<IExchange, int>, TimeSpan?, bool, ILogger?)
Creates a keyed throttle whose limit is evaluated on every message.
KeyedThrottleProcessor(IProcessor, Func<IExchange, string>, int, TimeSpan?, bool, ILogger?)
Creates a keyed throttle with a fixed limit per key.