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

Timeout configurable #101

Merged
merged 3 commits into from
Oct 8, 2024
Merged

Timeout configurable #101

merged 3 commits into from
Oct 8, 2024

Conversation

didierofrivia
Copy link
Member

@didierofrivia didierofrivia commented Oct 4, 2024

Closes #93

Example config:

extensions:
  limitador:
    type: "ratelimit",
    endpoint: "limitador-cluster",
    failureMode: "deny",
    timeout: "5s"
policies:
...

The timeout value must be string, and must be in the format of a duration. Default to 20ms

Examples of valid timeout values:

  • 1ms parses as 1 millisecond
  • 1.5ms parses as 1 millisecond and 500 microseconds
  • 5s parses as 5 seconds

Copy link
Member

@adam-cattermole adam-cattermole left a comment

Choose a reason for hiding this comment

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

Nice job, this seems to be working well! I also verified by changing one of the integration test configs and could see the timeout in the grpc request change. Just needs a rebase I think

Copy link
Member

@alexsnaps alexsnaps left a comment

Choose a reason for hiding this comment

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

lgtm, modulo that one comment on the negative durations. But this is internal again, so not a big deal, tho I'd create an issue if we don't fix it now in place. Thanks 🙏

src/configuration.rs Show resolved Hide resolved
E: Error,
{
match duration(Arc::new(string)) {
Ok(Value::Duration(duration)) => Ok(Timeout(duration.to_std().unwrap())),
Copy link
Member

Choose a reason for hiding this comment

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

I think this could be an issue here, if I understand this right a "CelDuration" can be negative, a std can't if I'm not mistaken. So we expose it as if it could, then would panic if one would provide a negative one, which would be nonsensible in any case tho...

Copy link
Member Author

Choose a reason for hiding this comment

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

you are correct, this would panic on a negative as OutOfRangeError(())

Signed-off-by: dd di cesare <didi@posteo.net>
Signed-off-by: dd di cesare <didi@posteo.net>
Signed-off-by: dd di cesare <didi@posteo.net>
@didierofrivia didierofrivia merged commit 1ac5db9 into main Oct 8, 2024
8 checks passed
@didierofrivia didierofrivia deleted the timeout-configurable branch October 8, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Make the timeout of the rate limit request configurable
3 participants