Class ThrottleProcessor
Limits the rate of exchange processing using a fixed-rate token release.
Thread-safe for concurrent pipeline usage. Disposable — call
to cancel pending slot-release timers on shutdown.
Two overflow modes (selected via the rejectOnOverflow constructor flag):
false (default, legacy) — semaphore-wait until a slot frees; the calling
exchange is blocked but eventually proceeds. Preserves backward compatibility.true (RFC 6585) — reject overflow exchanges immediately with HTTP 429
Too Many Requests and a Retry-After header (RFC 7231 §7.1.3) set to the
current rate-limit period. Strongly recommended for any HTTP-facing endpoint so
the client can back off explicitly instead of seeing what looks like a hung server.
public sealed class ThrottleProcessor : IProcessor, IDisposable
Inheritance
Implements
Methods
Dispose()
Cancels pending slot-release timers and wakes every waiter with a cancellation.
public void Dispose()
Process(IExchange, CancellationToken)
Processes the exchange asynchronously.
public Task Process(IExchange exchange, CancellationToken ct = default)
Constructors
ThrottleProcessor(IProcessor, Func<IExchange, int>, TimeSpan?, bool, ILogger?)
Creates a throttle processor whose limit is computed per exchange. The factory runs on
ThrottleProcessor(IProcessor, int, TimeSpan?, bool, ILogger?)
Creates a throttle processor with a fixed limit.