Skip to content

LavinMotwani/rateLimiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RateLimiter Library

A Java library for rate limiting, offering both Token Bucket and Leaky Bucket algorithms. Designed for easy integration into your Java, Maven, or Spring Boot projects.

Features

  • Token Bucket Algorithm: Flexible rate limiting with burst capability.
  • Leaky Bucket Algorithm: Smooth, steady rate limiting for consistent throughput.
  • Modular and extensible: Easily extend and integrate with your own services.
  • Suitable for API request limiting, resource usage throttling, and more.

Installation

Add the library to your Maven project:

<dependency>
    <groupId>com.yourorg</groupId>
    <artifactId>rateLimiter</artifactId>
    <version>1.0.0</version>
</dependency>

Replace com.yourorg and 1.0.0 with the actual group ID and version if different.

Usage

Extend the provided implementations or integrate the core classes directly into your application. Example (pseudo-code):

// Token Bucket Example
TokenBucketRateLimiter limiter = new TokenBucketRateLimiter(100, 10); // capacity, refill rate
if (limiter.allowRequest()) {
    // process request
}

// Leaky Bucket Example
LeakyBucketRateLimiter limiter = new LeakyBucketRateLimiter(50, 5); // capacity, outflow rate
if (limiter.allowRequest()) {
    // process request
}

Integration with Spring Boot

You can autowire or instantiate the rate limiter within your Spring services or controllers as needed. Customize or extend the base classes to fit your requirements.

Extending the Library

  1. Implement custom logic by extending the provided classes.
  2. Override the allowRequest() or relevant methods.
  3. Integrate with your APIs, background jobs, or any rate-limited resource.

Contributing

Contributions are welcome! Please fork the repo and submit pull requests. For major changes, open an issue first to discuss your ideas.

License

This project is licensed under the MIT License. See the LICENSE file for details.


For questions or support, please open an issue.

About

Rate Limiter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages