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

Fix matching scheme #6

Merged
merged 9 commits into from
Feb 6, 2017
Merged

Fix matching scheme #6

merged 9 commits into from
Feb 6, 2017

Conversation

junr03
Copy link
Member

@junr03 junr03 commented Feb 1, 2017

@lyft/network-team

The following request:

RateLimitRequest:
  domain: example
  descriptor: ("key", "value"),("subkey", "subvalue")

Would match the following config:

domain: example
descriptors:
  - key: key
    value: value
    rate_limit:
      -  requests_per_unit: 300
         unit: second

Arguably the request should not match that config, it should only match a config entry like this:

domain: example
descriptors:
  - key: key
    value: value
    descriptors:
      - key: subkey      
        rate_limit:
          -  requests_per_unit: 300
             unit: second

So in general the ratelimit service should match the most specific rule with the same depth level as the request.

README.md Outdated

#### Example 4

The Ratelimit service matches requests to configuration entries with the same depth level. For instance, the following request:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to define what you mean by depth level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@@ -265,7 +265,11 @@ func (this *rateLimitConfigImpl) GetLimit(

if nextDescriptor != nil && nextDescriptor.limit != nil {
logger.Debugf("found rate limit: %s", finalKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this logger statement be moved into the if below?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.


rl = rlConfig.GetLimit(
nil, "test-domain",
&pb.RateLimitDescriptor{[]*pb.RateLimitDescriptor_Entry{{"key5", "value5"}, {"subkey5", "subvalue"}}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to test here?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@ccaraman
Copy link
Contributor

ccaraman commented Feb 1, 2017

Once #2 has been merged, please update this pr to use consistent language when referring to depth vs descriptor list level example :https://github.com/lyft/ratelimit/blob/e6eb371b25f2214027f352c80a7ea56d86793cb7/README.md#descriptor-list-definition

README.md Outdated
*attempt the most specific match possible*. This means both the most nested matching descriptor entry, as well as
the most specific at any descriptor list level. Thus, key/value is always attempted as a match before just key.
*attempt the most specific match possible*. This means
the most specific descriptor at the same level as your request. Keep in mind that equally specific descriptors are matched on a first match basis. Thus, key/value is always attempted as a match before just key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rewrite the second sentence Keep in mind... what determines what is first? Order specified in the config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that sentence back.

@junr03 junr03 changed the base branch from docs to master February 2, 2017 22:38
README.md Outdated

## Loading Configuration

The Ratelimit service uses a library written by Lyft called [goruntime](https://github.com/lyft/goruntime) to do configuration loading. Goruntime monitors
>>>>>>> master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge conflict

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

README.md Outdated
@@ -178,13 +179,14 @@ RateLimitRequest:
descriptor: ("to_number", "2061111111")
```

And the service with rate limit against *all* matching rules and return an aggregate result.
And the service with rate limit against *all* matching rules and return an aggregate result; a logical OR of all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will instead of with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

#### Example 4

The Ratelimit service matches requests to configuration entries with the same level, i.e
same number of tuples in the request's descriptor as nested levels of descriptors
Copy link
Contributor

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...

Copy link
Member Author

@junr03 junr03 Feb 4, 2017

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.

README.md Outdated
descriptor: ("key", "value"),("subkey", "subvalue")
```

Would **not** match the following configuration, even though the first descriptor in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run together sentence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@junr03 junr03 merged commit 3c92419 into master Feb 6, 2017
@junr03 junr03 deleted the fix-matching branch February 6, 2017 21:02
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

Successfully merging this pull request may close these issues.

3 participants