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

Add rate limiter config and integration test #81

Merged
merged 8 commits into from
Aug 18, 2020

Conversation

iffyio
Copy link
Collaborator

@iffyio iffyio commented Aug 11, 2020

  • Make period optional, default to 1sec.
  • Reject configs with period < 100ms since we can't
    really guarantee correctness at lower resolutions.

Work on #5

* Make period optional, default to 1sec.
* Reject configs with period < 100ms since we can't
  really guarantee correctness at lower resolutions.

Work on #5
src/extensions/filter_registry.rs Outdated Show resolved Hide resolved
src/extensions/filters/local_rate_limit.rs Show resolved Hide resolved
}

/// A filter that implements rate limiting on packets based on
/// the token-bucket algorithm.
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have a config, can we add a configuration example like we do here: https://github.com/googleforgames/quilkin/blob/master/src/extensions/filters/debug_filter.rs#L28-L45 ?

I think it would be nice for our users 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added!

src/extensions/filters/local_rate_limit.rs Show resolved Hide resolved
src/extensions/filters/mod.rs Show resolved Hide resolved
let mut buf = vec![0; 1024];
let (size, sender) = socket.recv_from(&mut buf).await.unwrap();
socket.send_to(&buf[..size], sender).await.unwrap();
loop {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a way to shut this down at the end of a test? (we do this for other services)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I initially thought to check any error here and break but that wasn't really needed since the server is running for the duration of the test and we don't expect it to fail so unwrapping should be okay.
Shutting down would likely be to have tests signal this loop to exit and drop the RecvHalf socket - since the loop is running for the duration of the test either way, I'm don't think an explicit shutdown adds much given the extra code it'll add to tests that use echo_server.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #84 for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice issue.

/// local:
/// port: 7000 # the port to receive traffic to locally
/// filters:
/// - name: quilkin.extensions.filters.local_rate_limit.alphav1.LocalRateLimit
Copy link
Contributor

@markmandel markmandel Aug 14, 2020

Choose a reason for hiding this comment

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

I didn't notice this before - but we should probably come up with a documented standard for filters?

The debug filter is: "quilkin.core.v1alpaha1.debug"

Envoy has a pattern that looks more like: "envoy.extensions.filters.http.tap.v3.Tap" (link) - which is akin to what you have.

I don't have a huge opinion on what the standard is, but we should probably document this somewhere, yeah?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment mentioning a naming format, it follows the directory layout we're using for filters

@@ -73,7 +73,7 @@ impl DebugFilterFactory {

impl FilterFactory for DebugFilterFactory {
fn name(&self) -> String {
return String::from("quilkin.core.v1alpaha1.debug");
return String::from("quilkin.core.v1alpha1.debug");
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're going to fix my typo, should probably change the whole thing.

Suggested change
return String::from("quilkin.core.v1alpha1.debug");
return String::from("quilkin.extensions.filter.debug_filter.v1alpha1.DebugFilter");

(with update if we settle on filters vs filter)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missed that, fixed!

Copy link
Contributor

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

🙌

@markmandel markmandel merged commit c2498f9 into master Aug 18, 2020
@markmandel markmandel deleted the iu/rate-limiter-config branch August 18, 2020 15:15
@markmandel markmandel added area/tests Unit tests, integration tests, anything to make sure things don't break kind/feature New feature or request labels Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Unit tests, integration tests, anything to make sure things don't break cla: yes kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants