larzquota
One shared quota multiple apps draw from together.
For the case rate limiters don't cover: one external ceiling (a mailbox's hourly abuse limit, a paid API's per-minute cap) that several unrelated apps or crons all send against, with no fair static per-app split - a quiet app frees budget for a busy one. Ported from a real production guard. Atomicity across concurrent processes comes from a real flock-wrapped check-and-append, not a racy read-then-write. Fail-open on any error - a guard must never itself become the reason legitimate calls stop.
What you get
- Shared across independent processes, real flock atomicity
- Tiered caps by kind (transactional vs marketing, etc)
- Fail-open - never the reason sends stop
- remaining()/count() for introspection
Try it
import "quota" as quota
let caps = {"transactional": 3}
let allowed = 0
let denied = 0
let i = 0
while i < 5 {
if quota.check_and_record("/tmp/demo_quota.ledger", "transactional", caps, 3) { allowed = allowed + 1 } else { denied = denied + 1 }
i = i + 1
}
print("allowed:", allowed, "denied:", denied)
print("remaining:", quota.remaining("/tmp/demo_quota.ledger", "transactional", caps, 3))allowed: 3 denied: 2 remaining: 0
Why it's in the Larz Stack
larzquota is a real Larzscript package (larzscript pkg install quota) - 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.