A Go library for implementing timed rate limiting with both blocking and non-blocking approaches.
go-rate is a Go library that implements timed rate limiting to control how frequently operations can be performed. It solves problems like API rate limit compliance, server-side spam prevention, and preventing resource saturation by providing both blocking and non-blocking approaches to rate control.
Go developers building applications that need to respect rate limits, such as API clients, chat systems with spam protection, or services making external API calls.
Developers choose go-rate for its simple API, support for both blocking and non-blocking patterns, ability to combine multiple limiters, and proven production reliability with minimal dependencies.
A timed rate limiter for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The API is minimal with just rate.New, Wait(), and Try(), as shown in the examples, making it easy to integrate into existing Go codebases with little overhead.
Provides both blocking Wait() for precise rate adherence and non-blocking Try() for spam protection, demonstrated in the README with clear use cases.
Allows combining different rate limiters, as illustrated in the example with rl1 and rl2, enabling complex constraints like multiple API rate limits.
Used in production at LangTrend for GitHub API compliance, indicating reliability and real-world testing in demanding scenarios.
Based on fixed intervals, it lacks support for burst requests or token bucket algorithms, which can be limiting for applications needing variable rate control.
The library is designed for single-process use, with no built-in support for distributed rate limiting, making it unsuitable for clustered environments.
Uses a simple interval-based approach that might not be as efficient or flexible as more advanced algorithms, potentially leading to suboptimal performance in high-throughput scenarios.