- this rate limiter is based on the algorithm sliding window
- not found any solution in popular libraries (bucket4j, resilience4j, guava)
Some resources (example1 , example2) has some limits for accept user requests.
So application need to know (fast, without sent packets to any additional system) - can they send request or wait or skip
<dependency>
<groupId>io.github.axel-n</groupId>
<artifactId>limiter-sliding-window</artifactId>
<version>0.3</version>
</dependency>
compile "io.github.axel-n:limiter-sliding-window:0.3"
examples availble in another repository
@LimiterConfig(
instanceName = "common", // name of limiter config. you can use several limiters
maxTimeWait = @TimeConfig(value = 10, interval = TimeUnit.SECONDS), // optional
limitType = ExecutionLimitType.EXECUTE_OR_WAIT // also available EXECUTE_OR_THROW_EXCEPTION
)
public void limiterWrapperService() {
// call some your service
}
// use executeOrWait or executeOrThrowException
limiter.executeOrWait(() -> {
// run runnable or callable
});
- integrate deploy to maven repository
- add example without spring boot
- add methods for run something with limiter wrapper
- add tests in concurrency execution
- add example with spring boot
- add usage with annotation
- increase code coverage
- load values from values in specific environments (like slow github runner)
- add ability setup several limiters (for example 30 requests per 1 minute and 5 requests per second)
- add integration with monitoring
- add normal logging