Provides the following rate limiters:
The package also provides the following:
- Local (in-memory)
- A rate limiter configured with this store simply stores all data locally in memory. It evicts all keys that have not been touched in the last minute.
- Redis backed
- This provides a more reliable storage for the rate limiter.
- Every key has a TTL of one minute.
- Currently does not have TLS support.
- http
- a pluggable http middleware to make it easy for using the rate limiters.
- see example/ directory for usage.
The rate limiters can be configured via the LimiterOptions
type.
See example/main.go for hints.
- add TLS support for Redis store
- make the error message configurable (currently it returns a 429 status code with "Quota Exceeded" as the message)
- add GRPC middleware
- allow fetching limits per IP from a config source and use custom limits per client, and fall back to the global default limit if a client does not have a custom rate limit