Comments (4)
Hi @almightydegu , an IdentityId is a no-op without an IdentityIdExtractor (sorry if it is not clear from the documentation). That might be the reason of what you're observing.
Can you show your IdentityIdExtractor's code?
from throttlingtroll.
Thank you for the reply @scale-tone.
Below is the full object I'm using:
app.UseThrottlingTroll(options =>
{
options.IdentityIdExtractor = request =>
{
return ((IIncomingHttpRequestProxy)request).Request.RouteValues["testId"]?.ToString();
};
options.Config = new ThrottlingTrollConfig
{
Rules = new[]
{
new ThrottlingTrollRule
{
UriPattern = "test$",
IdentityId = "f411b023-dfb0-4756-9319-7bc24d11a682",
LimitMethod = new FixedWindowRateLimitMethod
{
IntervalInSeconds = 1000,
PermitLimit = 10
}
},
new ThrottlingTrollRule
{
UriPattern = "test$",
IdentityId = "758a3ff4-0655-4183-9406-20fbc8cb1bcc",
LimitMethod = new FixedWindowRateLimitMethod
{
IntervalInSeconds = 1000,
PermitLimit = 30
}
},
new ThrottlingTrollRule
{
UriPattern = "test$",
LimitMethod = new FixedWindowRateLimitMethod
{
IntervalInSeconds = 1000,
PermitLimit = 1
}
}
}
};
});
If I remove the third rule and just use the two rules that have the IdentityId
set, then it works as expected, but I want to have a default option to the set up I want
from throttlingtroll.
Then I suggest you return some my-default-identity-id
constant from your IdentityIdExtractor, when a request falls into this "default" category. And then have a separate ThrottlingTrollRule with IdentityId="my-default-identity-id".
That will not only work, but will also look explicit - leaves no doubt about how your system behaves.
Also remember, that ThrottlingTrollRule.IdentityId field is optional - when this value is omitted and IdentityIdExtractor is present, then all individual identities will get their separate counters automatically.
from throttlingtroll.
Doing that would mean all other requests would not be treated independently, which is what I was hoping for. I will need to create a rule for each of the IDs as a workaround. I mainly wanted this as a catch-all is a new ID is passed in without a rule and make the rules config cleaner to work with, but I can work around it
from throttlingtroll.
Related Issues (18)
- ArgumentOutOfRangeException "The absolute expiration value must be in the future." when using DistributedCacheCounterStore + Distributed Redis Cache HOT 1
- [DistributedCacheCounterStore + Distributed Redis Cache] TTL is rounded to the nearest second, therefore setting interval to 1s does not make sense
- [Optimization] Cache the fact that a particular limit is exceeded HOT 1
- Custom response builders HOT 1
- Port to Azure Functions (Isolated) HOT 1
- Make Rule's 'Method' property comma-separated HOT 1
- Allow specifying IdentityIdExtractor at ThrottlingTrollOptions level as well HOT 1
- Implement Azure Table/Cosmos DB counter store HOT 1
- Support Functions ASP.NET Core Integration HOT 1
- Bug When 2 rules assigned to same identity or Endpoint. HOT 1
- Microsoft.AspNetCore.Http is deprecated, need to get rid of it HOT 1
- Feature Request for Azure Functions: Retrieval of Rate Limiting Values HOT 5
- How to implement limit per identity? HOT 4
- Issue with redis counter store HOT 2
- Implement declarative (attribute-based) configuration HOT 1
- Implement SQL counter store HOT 1
- Add ReleaseAfterSeconds property to Semaphore algorithm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from throttlingtroll.