Skip to content

Repository files navigation

In-memory token-bucket rate limiter

TokenBucket.java

This utility enforces API throughput limits using standard Java concurrency primitives. Local state avoids network partition risks during core transaction processing.

Time-dependent logic requires strict clock control. The main gotcha is thread contention when advancing the mock clock across concurrent bucket checks. Inject a monotonic clock interface to keep audit tests deterministic.

About

A small, time-injectable token-bucket rate limiter — no Redis, no dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages