package polymarket
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/polymarket.rate_limiter/Polymarket_rate_limiter/Gcra/index.html
Module Polymarket_rate_limiter.GcraSource
Generic Cell Rate Algorithm (GCRA) for rate limiting.
GCRA tracks a theoretical arrival time (TAT) for the next request. It provides fair rate limiting with configurable burst capacity.
For a limit of N requests per T seconds:
- Sustained rate: N/T requests per second
- Burst capacity: N requests (the full quota can be used immediately)
The algorithm ensures that over any T-second window, no more than N requests are allowed, while permitting short bursts when there's available quota.
GCRA state for a single limit
Create a new GCRA state from a limit configuration
Check if a request is allowed at the given time.
Update state after a request is allowed. Must be called after check returns Ok () and before releasing any locks.
Combined check and update. Atomically checks if allowed and updates state.
Calculate seconds until the next request can proceed
Get the emission interval (time between requests at sustained rate)