RateLimiterConfig

Configuration for a RateLimiter.

This class holds the settings that define the behavior of the rate limiter, such as the number of permitted calls within a specific time period.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The maximum number of calls that are permitted in a given period. Defaults to 100.

Link copied to clipboard
var onRateLimited: suspend () -> Unit

A suspendable lambda function that is executed when a call is rate-limited. This can be used for logging or other side effects. When the policy is built via com.santimattius.resilient.composition.resilient, the builder injects a telemetry callback that runs first (emitting com.santimattius.resilient.telemetry.ResilientEvent.RateLimited), then onRateLimited is invoked.

Link copied to clipboard

The time period during which maxCalls are allowed. Defaults to 1 second.

Link copied to clipboard

The optional duration to wait for a permit if the rate limit is exceeded. If null (the default), calls will fail immediately with a RateLimitExceededException when the limit is reached. If set, the call will be suspended for up to this duration, waiting for a permit to become available.