Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is requestLimitRules really needed at the time of RedisSlidingWindowRequestRateLimiter creation? #14

Closed
Meyy-DL opened this issue Apr 14, 2018 · 2 comments

Comments

@Meyy-DL
Copy link

Meyy-DL commented Apr 14, 2018

Thank you for all your hard work. Am trying to include your work and realized we must have requestLimitRules in hand before we create RedisSlidingWindowRequestRateLimiter instance. I would like to create vanilla RedisSlidingWindowRequestRateLimiter instance during application startup and inject different rules at different point in the process.

So I was looking at your code and thinking whether we can create vanilla/generic RedisSlidingWindowRequestRateLimiter without tying to limit rules and expose public method to pass in serialized rules later when needed?

Something like
public RedisSlidingWindowRequestRateLimiter(StatefulRedisConnection<String, String> connection)

Highly appreciate your thoughts on my approach.

@mokies
Copy link
Owner

mokies commented Apr 14, 2018

You should be able to use RedisRateLimiterFactory for this purpose. I have used RedisRateLimiterFactory in the dropwizard module to dynamically create instances of RedisSlidingWindowRequestRateLimiter. While RedisRateLimiterFactory is fairly lightweight to construct the RedisRateLimiterFactory has a small internal cache of instances should this be a concern.

@Meyy-DL
Copy link
Author

Meyy-DL commented Apr 17, 2018

Looking at the implementation, I guess thats what I was looking for. It would be nice to document these use cases somewhere for future reference. Thanks @mokies!

@Meyy-DL Meyy-DL closed this as completed Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants