RateLimitedHttpClient class

: an HttpClient that wraps an inner client and rate-limits the requests using a token bucket. If the bucket is empty, requests block until a token is available.

Implemented types

Constructors

RateLimitedHttpClient({required HttpClient inner, required double tokensPerSecond, int burst = 1})
: creates a rate-limited wrapper.
RateLimitedHttpClient.forTesting({required HttpClient inner, required double tokensPerSecond, required int burst, double initialTokens = 0})
: factory for tests — exposes the initial state of the bucket.
factory

Properties

availableTokens double
: the number of available tokens right now. Useful for tests.
no setter
burst int
final
hashCode int
The hash code for this object.
no setterinherited
inner HttpClient
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tokensPerSecond double
final

Methods

close() Future<void>
Permite liberar recursos. Por defecto es no-op.
override
execute(RestRequest request, {required Decoder decoder, CancelToken? cancelToken}) Future<RestResponse>
Ejecuta la petición y devuelve una respuesta "cruda" (todavía sin decodificar el body a un tipo concreto). El RestClient se encarga de aplicar el Decoder.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited