Skip to content

feat: allow to set custom timeout for route#4340

Merged
tokers merged 5 commits into
apache:masterfrom
yxudong:yxd
Jun 1, 2021
Merged

feat: allow to set custom timeout for route#4340
tokers merged 5 commits into
apache:masterfrom
yxudong:yxd

Conversation

@yxudong

@yxudong yxudong commented May 30, 2021

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Add optional upstream_timeout option for the route.
#4258

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Comment thread apisix/balancer.lua Outdated
Comment thread apisix/schema_def.lua Outdated
Comment thread docs/en/latest/admin-api.md Outdated
Comment thread apisix/balancer.lua Outdated
@@ -136,8 +136,18 @@ end
-- set_balancer_opts will be called in balancer phase and before any tries
local function set_balancer_opts(ctx)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can pass route directly:

function _M.run(route, ctx)

Comment thread apisix/schema_def.lua Outdated
minItems = 1,
uniqueItems = true,
},
timeout = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better to exact the timeout to a separate schema.

Comment thread t/admin/routes2.t



=== TEST 18: valid route with timeout

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to add test to t/node/timeout-upstream.t

@yxudong
yxudong requested a review from spacewander May 31, 2021 03:51
Comment thread apisix/schema_def.lua Outdated
minItems = 1,
uniqueItems = true,
},
upstream_timeout = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May abstract the timeout schema so it can be reused by route and upstream schema.

Comment thread docs/en/latest/admin-api.md Outdated
| script | False | Script | See [Script](architecture-design/script.md) for more | |
| upstream | False | Upstream | Enabled Upstream configuration, see [Upstream](architecture-design/upstream.md) for more | |
| upstream_id | False | Upstream | Enabled upstream id, see [Upstream](architecture-design/upstream.md) for more | |
| upstream_timeout | False | Upstream | Set the upstream timeout for connection, sending and receiving messages of the route. This option will overwrite the [timeout](#upstream) option which set in upstream configuration. | {"connect": 3, "send": 3, "read": 3} |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
| upstream_timeout | False | Upstream | Set the upstream timeout for connection, sending and receiving messages of the route. This option will overwrite the [timeout](#upstream) option which set in upstream configuration. | {"connect": 3, "send": 3, "read": 3} |
| upstream_timeout | False | Upstream | Set the upstream timeout for connecting, sending and receiving messages of the route. This option will overwrite the [timeout](#upstream) option which set in upstream configuration. | {"connect": 3, "send": 3, "read": 3} |

Comment thread t/admin/routes2.t Outdated



=== TEST 18: valid route with upstream_timeout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need further test cases to cover the usage of upstream_timeout.

@yxudong
yxudong requested a review from tokers June 1, 2021 03:04
@tokers
tokers merged commit 91a048e into apache:master Jun 1, 2021
@yxudong
yxudong deleted the yxd branch June 2, 2021 09:40
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