Zero dependencies · 零依赖
Only the JDK — no framework, no logging binding, no JSON library, no Redis client. 只用 JDK,没有框架、日志绑定、JSON 库或 Redis 客户端。
Six algorithms in one 18 KB jar, Java 8+, zero dependencies, no background threads. 六种算法、单个 18 KB jar、零依赖、无后台线程。
Same configuration, six admission patterns: a burst then steady, evenly paced, a rolling window that refuses the boundary trick, a fixed window that hands out twice the rate across a clock tick, a cold start that ramps up, and a bulkhead that ignores the clock. 同一配置、六种放行形态。
<dependency>
<groupId>io.github.onblog</groupId>
<artifactId>java-limiter</artifactId>
<version>1.0.0</version>
</dependency>RateLimiter limiter = RateLimiters.tokenBucket("api", 200, 100, Duration.ofSeconds(1));
if (limiter.tryAcquire()) {
handleRequest();
} else {
response.setStatus(429);
}