Effect Token Bucket Shaper
Rate limiting that allows a real burst but bounds the true rate. A fixed window counted in wall-clock minutes admits 1000 at 0:59 and 1000 more at 1:00, so 2000 requests land in two seconds, the exact spike the limit forbids. A token bucket meters continuously: tokens refill at a steady rate with no boundary reset, and capacity sets the burst a normal page load is allowed before throughput settles to the refill rate. Lazy refill computes accrued tokens from elapsed logical time in one Ref.modify per request, so concurrent requests can never both spend the same token. The demo: 50 racing requests for a 1-token bucket admit exactly 1. Pinned to effect 4.0.0-beta.98.
npx shadcn@latest add https://ui.aryank.space/r/effect-token-bucket-shaper.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
A fixed window counted on the clock minute admits 10 at 0:59 and 10 more at 1:00. Twenty requests land in a fraction of a second: the exact 2x boundary burst the limit forbids.