Skip to main content

Module rate_limit

Module rate_limit 

Source
Expand description

How much one worker process may ask of each rate-limited Suotar endpoint.

One token bucket per endpoint, in memory like the circuit breaker: every endpoint is called from one process only. After its own failures, or when the breaker trips or closes again, an endpoint drops to a tenth of its rate and doubles back every five healthy minutes.

Keyed by scope like the breaker, so a test’s scoped ticks never spend what the live workers or another test may send.

StructsΒ§

Bucket πŸ”’
EndpointRate πŸ”’
What an endpoint may take at full rate.
LimiterSnapshot πŸ”’
One endpoint’s limiter as it stands, for the dashboard.

ConstantsΒ§

FLOOR_SHARE πŸ”’
The share of the full rate an endpoint drops to.
LIMITED_ENDPOINTS πŸ”’
The endpoints endpoint_rate limits.
RAMP_DOUBLING_INTERVAL πŸ”’
The reduced share doubles after each of these without a failure.

StaticsΒ§

BUCKETS πŸ”’
REPORTED πŸ”’
The global limiters as this process last wrote them for the dashboard.

FunctionsΒ§

available πŸ”’
How many items, or requests, the endpoint may take right now. Unlimited endpoints answer usize::MAX.
burst_limit πŸ”’
At least one, so an endpoint whose capacity is a couple of requests still gets one through at the floor.
drop_to_floor πŸ”’
Drops endpoints to FLOOR_SHARE of their rate, restarting the climb back. Unlimited ones are skipped.
endpoint_rate πŸ”’
The rate an endpoint is limited to, or None for one that is not limited.
overdraw πŸ”’
Spends count even past what available allows, into debt that later refills pay off first, capped at one capacity so recovery takes at most one refill. Only for a split batch’s resent halves, which must not wait for a later iteration and re-claim the same batch.
reset πŸ”’
Forgets every bucket of scope, so its endpoints are back at full rate with a full burst.
snapshot πŸ”’
None for an unlimited endpoint.
take πŸ”’
Spends count of what available allowed.
with_bucket πŸ”’