-
Notifications
You must be signed in to change notification settings - Fork 509
Fix matching scheme #6
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
Changes from all commits
7f103ab
e6eb371
4c7ea53
51c94ab
53b34a6
7631bc1
90fd9fb
0d1f996
fe0e5da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -251,7 +251,7 @@ func (this *rateLimitConfigImpl) GetLimit( | |
| } | ||
|
|
||
| descriptorsMap := value.descriptors | ||
| for _, entry := range descriptor.Entries { | ||
| for i, entry := range descriptor.Entries { | ||
| // First see if key_value is in the map. If that isn't in the map we look for just key | ||
| // to check for a default value. | ||
| finalKey := entry.Key + "_" + entry.Value | ||
|
|
@@ -265,7 +265,11 @@ func (this *rateLimitConfigImpl) GetLimit( | |
|
|
||
| if nextDescriptor != nil && nextDescriptor.limit != nil { | ||
| logger.Debugf("found rate limit: %s", finalKey) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this logger statement be moved into the if below?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think so. In debug we want to know about all the ratelimits found, the next logger message would let us know if the ratelimit was not chosen. |
||
| rateLimit = nextDescriptor.limit | ||
| if (i == len(descriptor.Entries) - 1) { | ||
| rateLimit = nextDescriptor.limit | ||
| } else { | ||
| logger.Debugf("request depth does not match config depth, there are more entries in the request's descriptor") | ||
| } | ||
| } | ||
|
|
||
| if nextDescriptor != nil && len(nextDescriptor.descriptors) > 0 { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,16 @@ func TestBasicConfig(t *testing.T) { | |
| &pb.RateLimitDescriptor{[]*pb.RateLimitDescriptor_Entry{{"key1", "value1"}}}) | ||
| assert.Nil(rl) | ||
|
|
||
| rl = rlConfig.GetLimit( | ||
| nil, "test-domain", | ||
| &pb.RateLimitDescriptor{[]*pb.RateLimitDescriptor_Entry{{"key2", "value2"}, {"subkey", "subvalue"}}}) | ||
| assert.Nil(rl) | ||
|
|
||
| rl = rlConfig.GetLimit( | ||
| nil, "test-domain", | ||
| &pb.RateLimitDescriptor{[]*pb.RateLimitDescriptor_Entry{{"key5", "value5"}, {"subkey5", "subvalue"}}}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are you trying to test here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The config did not get pushed in the branch. Just updated. I am testing that RL will not return a limit for two tuples, even though there was a descriptor with less nesting in the config that matched. |
||
| assert.Nil(rl) | ||
|
|
||
| rl = rlConfig.GetLimit( | ||
| nil, "test-domain", | ||
| &pb.RateLimitDescriptor{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should this same level description go up higher? I don't know...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could argue for or against. Each example explains something about matching, and how this works so it takes all four examples to understand.