A generic rate limiter implementation in Go.
There are a few main concepts:
- Identifier: Provides a way to identify the request (e.g. IPIdentifier, TokenIdentifier)
- Store: Stores the counter (e.g. MemoryStore, FileStore, RedisStore)
- Limiter: Decides if a call is allowed (e.g. FixedWindowLimiter, SlidingWindowLog)
I've used Fixed Window Counter algorithm for this implementation as it's space efficient and easy to implement.
make run
make run-local
make test
make test-local