Developer Tooling ยท zero-dependency ยท MIT

larzlimit

Rate limiting.

Sliding-window, fixed-window and token-bucket rate limiters, per-key, with guard() that throws a 429-shaped error when a caller is over budget - the same shape a WSGI middleware would use, minus WSGI itself (Larzscript has no WSGI/ASGI concept to hook into).

larzscript pkg install limit
View on GitHub →Learn the stack

What you get

Try it

import "limit" as limit
let l = limit.token_bucket(3, 1)
print(limit.allow(l, "user-1", 0.0))
print(limit.allow(l, "user-1", 0.0))
print(limit.allow(l, "user-1", 0.0))
print(limit.allow(l, "user-1", 0.0))
Output
true
true
true
false

Why it's in the Larz Stack

larzlimit is a real Larzscript package (larzscript pkg install limit) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.