-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: allow to set custom timeout for route #4340
Changes from 2 commits
af5df84
66aed36
52778af
9cb1f39
b4cf24b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,6 +491,15 @@ _M.route = { | |
minItems = 1, | ||
uniqueItems = true, | ||
}, | ||
upstream_timeout = { | ||
Yiyiyimu marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
type = "object", | ||
properties = { | ||
connect = {type = "number", exclusiveMinimum = 0}, | ||
send = {type = "number", exclusiveMinimum = 0}, | ||
read = {type = "number", exclusiveMinimum = 0}, | ||
}, | ||
required = {"connect", "send", "read"}, | ||
}, | ||
vars = { | ||
type = "array", | ||
}, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -88,6 +88,7 @@ Note: When the `Admin API` is enabled, it will occupy the API prefixed with `/ap | |||||
| 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} | | ||||||
Yiyiyimu marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| service_id | False | Service | Binded Service configuration, see [Service](architecture-design/service.md) for more | | | ||||||
| plugin_config_id | False, can't be used with `script` | Plugin | Binded plugin config object, see [Plugin Config](architecture-design/plugin-config.md) for more | | | ||||||
| labels | False | Match Rules | Key/value pairs to specify attributes | {"version":"v2","build":"16","env":"production"} | | ||||||
|
@@ -117,6 +118,11 @@ Config Example: | |||||
"vars": [["http_user", "==", "ios"]], # A list of one or more `[var, operator, val]` elements | ||||||
"upstream_id": "1", # upstream id, recommended | ||||||
"upstream": {}, # upstream, not recommended | ||||||
"upstream_timeout": { # Set the upstream timeout for connection, sending and receiving messages of the route. | ||||||
"connect": 3, | ||||||
"send": 3, | ||||||
"read": 3 | ||||||
}, | ||||||
"filter_func": "", # User-defined filtering function | ||||||
} | ||||||
``` | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -650,3 +650,40 @@ GET /t | |
{"error_msg":"failed to fetch plugin config info by plugin config id [not_found], response code: 404"} | ||
--- no_error_log | ||
[error] | ||
|
||
|
||
|
||
=== TEST 18: valid route with upstream_timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need further test cases to cover the usage of |
||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local t = require("lib.test_admin").test | ||
local code, body = t('/apisix/admin/routes/1', | ||
ngx.HTTP_PUT, | ||
[[{ | ||
"methods": ["GET"], | ||
"upstream": { | ||
"nodes": { | ||
"127.0.0.1:8080": 1 | ||
}, | ||
"type": "roundrobin" | ||
}, | ||
"upstream_timeout": { | ||
"connect": 3, | ||
"send": 3, | ||
"read": 3 | ||
}, | ||
"uri": "/index.html" | ||
}]] | ||
) | ||
|
||
ngx.status = code | ||
ngx.say(body) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
passed | ||
--- no_error_log | ||
[error] |
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.
We can pass route directly:
apisix/apisix/balancer.lua
Line 247 in 09e2983