SpeedBump is a powerful and flexible rate limiting library for Go, designed to protect your web applications and APIs from overuse and to ensure equitable resource access across all users. At its core, SpeedBump utilizes Cloudflare's sliding window counter algorithm, offering a sophisticated approach to rate limiting that balances fairness and efficiency. This method ensures that request limits are enforced smoothly over time, preventing bursts of traffic from unfairly consuming resources.
go get github.com/prophet7821/speedBump.git
SpeedBump provides a suite of functionalities to easily integrate rate limiting into your Go applications. Below is a table summarizing the available functions:
Function | Description | Example |
---|---|---|
Limit |
Applies rate limits with customizable options. |
|
LimitAll |
Applies a global rate limit across all requests. |
|
LimitByIP |
Limits requests based on the client's IP address. |
|
WithKeyFuncs |
Allows setting custom key functions for rate limiting. |
|
KeyByIP/EndPoint |
Provides built-in key functions for identifying requests. |
|
WithLimitHandler |
Customizes the response for rate-limited requests. |
|
WithLimitCounter |
Enables the use of a custom limit counter. | See below for integrating with Redis |
WithRedisLimitCounter |
Integrates Redis for distributed rate limiting. |
|
We welcome contributions to the SpeedBump project! Whether it's adding new features, fixing bugs, improving documentation, or sharing feedback, your collaboration is highly appreciated. Please feel free to submit pull requests, report issues, or suggest improvements. Let's work together to make SpeedBump even better for the community.