Skip to main content

Module gcra

Module gcra 

Source
Expand description

GCRA (Generic Cell Rate Algorithm) rate limiter core.

GCRA is a token-bucket equivalent that stores a single value per key: the theoretical arrival time (TAT). Compared with a fixed window it has no boundary burst (a client cannot spend two full windows across a boundary) and it lets legitimate bursts through up to a configured capacity while throttling sustained abuse to the steady rate.

This module is pure arithmetic with an injected clock, so the burst boundary, refill, and clock-skew behaviour are all unit-testable without a store or a real clock.

Structs§

Gcra
A GCRA limiter parameterised by a steady emission interval and a burst tolerance. Construct one from a Profile with Gcra::from_profile.
Profile
A named limit tier: a sustained rate over a window plus an instantaneous burst capacity.
Verdict
The outcome of a single GCRA check.