RequestThrottle class
Token-bucket throttle for outbound HTTP traffic.
Limits the rate at which wrapped calls may reach a shared downstream. The public MultiversX hosts enforce per-IP ceilings at the edge — 50 requests per second on the Gateway hosts, 2 per second on the mainnet API host and 5 on the devnet API host — and answer 429 above them. Sizing the bucket to the ceiling smooths bursts that would otherwise be rejected.
A provider wires one of these automatically when
NetworkProviderConfig.throttlePolicy is enabled; construct it directly
only to throttle calls this SDK does not make.
Example
final throttle = RequestThrottle(capacity: 50, refillPerSecond: 50);
await throttle.acquire();
final response = await dio.get(url);
Constructors
- RequestThrottle({required int capacity, required double refillPerSecond})
Properties
- capacity → int
-
Maximum burst allowed before throttling kicks in.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- refillPerSecond → double
-
Tokens replenished per second.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acquire(
) → Future< void> - Acquires one token, waiting if the bucket is empty.
-
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