-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: add pre check for rate limit #194
feat: add pre check for rate limit #194
Conversation
src/server.rs
Outdated
@@ -51,6 +51,12 @@ pub async fn build(config: Config) -> anyhow::Result<SubwayServerHandle> { | |||
|
|||
let rpc_method_weights = MethodWeights::from_config(&config.rpcs.methods); | |||
|
|||
// pre-check stage | |||
if let Some(r) = &rate_limit_builder { |
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.
if you want to check this then just make sure no weight is greater than burst (ip or connection)
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.
Yeah, The result is fixed if config is not changed, so we should do pre-check.
Oherwise how do we know the config is correct.
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 can simple verify config file
This code is doing what you said. |
no it's not. you're adding additional code that needs to be maintained and no necessary at all. |
That's not true, you just assumed You could try run this branch and master branch, it do need extra check. Wait, maybe we just need to move this validation logic to there. But we still need such check logic. Now:
|
Wonder the behavior design: why still continue the service when validation failed. |
because it runs on it's own thread. it should work for any period |
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.
some tests will be nice
@xlc @yjhmelody In case you missed this |
Hi, you are right, I have simplify the code. |
* feat: pre-check for ip/connection rate limit * clean up docs * fix * do pre-check in `validate` fn * ok_or * add tests and simplify validate
The outer result of
until_key_n_ready_with_jitter
should be checked before start service, it's static result relatively .And its meaning is the cap is insufficient for
n
.