PRO

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.

Install
npx shadcn@latest add @compronents/effect-token-bucket-shaper

Installs from ui.aryank.space. Needs a registry token and a one-time @compronents entry in components.json. The docs walk through both.

Visualization
limiter
burst
{ count: number; windowStart: number }
admitted / sec
0
if (now - windowStart >= 1000) count = 0 // resets, leaks 2x

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.

Files
Checking access…
Dependencies