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

feat: add additional option to control the default_conn_delay option of the limit-conn plugin #4604

Merged
merged 22 commits into from
Jul 22, 2021
Merged

feat: add additional option to control the default_conn_delay option of the limit-conn plugin #4604

merged 22 commits into from
Jul 22, 2021

Conversation

zuiyangqingzhou
Copy link
Contributor

What this PR does / why we need it:

feat: issues

ps:

I'm thinking how to do the unit test here

Because I cannot verify the logic of the third-party library lua-resty-limit-traffic, I can only verify whether nil is passed for the req_latency parameter, but what should I do with this unit test?

Can you give some advice?

@@ -40,7 +40,7 @@ Limiting request concurrency plugin.
| conn | integer | required | | conn > 0 | the maximum number of concurrent requests allowed. Requests exceeding this ratio (and below `conn` + `burst`) will get delayed(the latency seconds is configured by `default_conn_delay`) to conform to this threshold. |
| burst | integer | required | | burst >= 0 | the number of excessive concurrent requests (or connections) allowed to be delayed. |
| default_conn_delay | number | required | | default_conn_delay > 0 | the latency seconds of request when concurrent requests exceeding `conn` but below (`conn` + `burst`). |
| delay_strict_mode | boolean | optional | false | [true,false] | enable the strict mode of the latency seconds. If you set this option to `true`, it will run strictly according to the latency seconds you set without additional calculation logic. |
| delay_strict_mode | boolean | optional | false | [true,false] | enable the strict mode of the latency seconds. If you set this option to `true`, it will run strictly according to the latency seconds you set without additional calculation logic. |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the option name is not so straightforward but I didn't come out with a more proper one :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😂

Copy link
Member

Choose a reason for hiding this comment

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

What about only_use_default_delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only_use_default_delay, use_default_conn_delay, apply_default_conn_delay, stint_default_conn_delay, Which of the four do you think is better, or do you have better suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

I vote for the first one. What about others' opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tokers what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Vote for the first one too, it's easy to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will change it to this one.
What about the test case I mentioned above? Any suggestions? @spacewander @tokers

Copy link
Member

Choose a reason for hiding this comment

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

You can take a look at the test in #4585

docs/zh/latest/plugins/limit-conn.md Outdated Show resolved Hide resolved
t/plugin/limit-conn2.t Outdated Show resolved Hide resolved
--- request
GET /hello1
--- grep_error_log eval
qr/request latency is/
Copy link
Member

Choose a reason for hiding this comment

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

Need to check latency in this mode is nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know exactly what you mean,

https://github.com/apache/apisix/pull/4604/files/47dc32979a94977aa8e3d0e73270dc88a9c43149#diff-2f0a07663e8e90e9f64519ee946aaf82729c8bb43e4f9100902e87d0a325f78eR251-R253

hasn't grep_error_log_out already check that the latency is nil?
Or would you give some guidance on how to do it ?

Copy link
Member

Choose a reason for hiding this comment

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

The grep pattern should be request latency is nil.

--- grep_error_log eval
qr/request latency is/
--- grep_error_log_out
request latency is
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
request latency is
request latency is nil

@spacewander spacewander merged commit f406218 into apache:master Jul 22, 2021
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.

4 participants