-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use dependency injection for IConnectionMultiplexer #5
Comments
I'm trying to figure out what needs to be done here, would it be possible to add some description? |
I don't really like the fact that we have to send the 'ConnectionMultiplexer' as an option to the rate limiters - wanted to somehow get it behind-the-hood from the Services Container. However, I don't think there's much we can do for now - we're limited by the way the framework's rate limiting middleware works and is configured |
If wanted you can use the HTTP context Maybe this example will help someone: public static RateLimiterOptions AddRedisFixedWindowLimiter(this RateLimiterOptions options, string policyName,
Action<RedisFixedWindowRateLimiterOptions, IServiceProvider> configure)
{
ArgumentNullException.ThrowIfNull(configure, nameof(configure));
var key = new PolicyNameKey(policyName);
return options.AddPolicy(policyName, (context) =>
RedisRateLimitPartition.GetFixedWindowRateLimiter(key, (_) =>
{
var windowsOptions = new RedisFixedWindowRateLimiterOptions();
configure(windowsOptions, context.RequestServices);
return windowsOptions;
}));
} |
when you redesign this , please keep in mind that IConnectionMultiplexer can come from another application (system) , right now it is ok because there is a public property for IConnectionMultiplexer |
No description provided.
The text was updated successfully, but these errors were encountered: