mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-04 21:17:36 +08:00
feat: also call picker.after_balance before retry (#2350)
This commit is contained in:
parent
50c99a5e3b
commit
16a2d4dfa9
@ -172,6 +172,10 @@ local function pick_server(route, ctx)
|
||||
return nil, "no valid upstream node"
|
||||
end
|
||||
|
||||
if ctx.server_picker and ctx.server_picker.after_balance then
|
||||
ctx.server_picker.after_balance(ctx, true)
|
||||
end
|
||||
|
||||
if up_conf.timeout then
|
||||
local timeout = up_conf.timeout
|
||||
local ok, err = set_timeouts(timeout.connect, timeout.send,
|
||||
|
@ -146,7 +146,12 @@ local function _ewma_find(ctx, up_nodes)
|
||||
end
|
||||
|
||||
|
||||
local function _ewma_after_balance(ctx)
|
||||
local function _ewma_after_balance(ctx, before_retry)
|
||||
if before_retry then
|
||||
-- don't count tries which fail to complete
|
||||
return nil
|
||||
end
|
||||
|
||||
local response_time = tonumber(ctx.var.upstream_response_time) or 0
|
||||
local connect_time = tonumber(ctx.var.upstream_connect_time) or 0
|
||||
local rtt = connect_time + response_time
|
||||
|
@ -672,7 +672,7 @@ function _M.http_log_phase()
|
||||
healcheck_passive(api_ctx)
|
||||
|
||||
if api_ctx.server_picker and api_ctx.server_picker.after_balance then
|
||||
api_ctx.server_picker.after_balance(api_ctx)
|
||||
api_ctx.server_picker.after_balance(api_ctx, false)
|
||||
end
|
||||
|
||||
if api_ctx.uri_parse_param then
|
||||
|
Loading…
Reference in New Issue
Block a user