coveooss/spillway ? reverse-engineered prompt

Reverse engineered prompt

Build me a simple Java library for distributed rate limiting that I can drop into a public API.

I want to be able to define limits like per user or per IP, set how many calls are allowed in a time window, and then wrap a resource so it can block or reject calls when the limit is exceeded. It should work across multiple JVMs, not just inside one app, and it should support both in memory storage for easy local use and Redis for shared usage. If the external storage has issues, it should be possible to use it asynchronously so the app does not slow down or fail completely.

Please include a clean way to trigger a callback when a limit is hit, plus both a throw on exceed style and a try and return true or false style. Look up current docs online if you need to, and make the API feel simple and easy to use.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab