AdaptiveRateLimiter

A client-side rate limiter backed by a token bucket. This limiter adaptively updates the refill rate of the bucket based on the number of successful transactions vs throttling errors. This limiter applies a smoothing function in an attempt to converge on the ideal transaction rate feasible for downstream systems.

Constructors

Link copied to clipboard
constructor(config: AdaptiveRateLimiter.Config = Config.Default)

Initializes a new AdaptiveRateLimiter

Types

Link copied to clipboard

The configuration for an adaptive client-side rate limiter

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open suspend override fun acquire(cost: Int)

Acquire a "permit" to conduct a transaction. If not enough permits are available, this method may delay.

Link copied to clipboard
open suspend override fun update(errorType: RetryErrorType?)

Update the rate limiter with the result of a transaction. The rate limiter may use this information to adjust the number of available permits or the rate at which permits refill.