pub struct SignerLimiter { /* private fields */ }Expand description
Per-signer trading limiter, with the tier discovered from response headers.
Starts at Tier::Standard — the tightest — and resizes both buckets the
first time a Poly-RateLimit-Tier header reports something different.
§The resize discards accumulated state
governor buckets cannot be resized in place, so adopting a new tier replaces them with fresh ones at full capacity. Moving up a tier is therefore safe: the venue already permits the wider allowance. Moving down briefly permits a full burst at the narrower capacity, which the venue may throttle. Tier changes are rare (they track 30-day volume), so this is preferred to the complexity of draining the old bucket into the new one.
Implementations§
Source§impl SignerLimiter
impl SignerLimiter
Sourcepub fn last_status(&self) -> RateLimitStatus
pub fn last_status(&self) -> RateLimitStatus
The most recent Poly-RateLimit-* telemetry seen.
Sourcepub fn observe(&self, headers: &HeaderMap)
pub fn observe(&self, headers: &HeaderMap)
Record the rate-limit headers from a response, adopting a reported tier.
Responses carrying none of the headers are ignored, so non-trading requests cannot clear the telemetry.
Sourcepub async fn acquire(
&self,
request: TradingRequest,
) -> Result<(), BurstCapacityExceeded>
pub async fn acquire( &self, request: TradingRequest, ) -> Result<(), BurstCapacityExceeded>
Wait for request’s token cost to be available, then consume it.
§Errors
BurstCapacityExceeded when the cost exceeds the bucket’s capacity.
This returns immediately rather than waiting forever.
Trait Implementations§
Source§impl Clone for SignerLimiter
impl Clone for SignerLimiter
Source§fn clone(&self) -> SignerLimiter
fn clone(&self) -> SignerLimiter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more