Skip to content

Commit

Permalink
rename handler to xrpc_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan committed Sep 20, 2024
1 parent 2a8df75 commit 0ba9414
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ end
-- Runs a single healthcheck probe
function checker:run_single_check(ip, port, hostname, hostheader)
if self.checks.active.type == "xrpc" then
local ok, status = self.checks.active.handler({
local ok, status = self.checks.active.xrpc_handler({
host = ip,
port = port,
domain = hostname,
Expand Down Expand Up @@ -1327,7 +1327,7 @@ local defaults = {
concurrency = 10,
http_path = "/",
https_verify_certificate = true,
handler = NO_DEFAULT,
xrpc_handler = NO_DEFAULT,
xrpc_conf = {},
healthy = {
interval = 0, -- 0 = disabled by default
Expand Down Expand Up @@ -1456,7 +1456,7 @@ function _M.new(opts)
end

if self.checks.active.type == "xrpc" then
assert(self.checks.active.handler, "required option 'checks.active.handler' is missing")
assert(self.checks.active.xrpc_handler, "required option 'checks.active.xrpc_handler' is missing")
assert(self.checks.active.unhealthy.failures < 255, "checks.active.unhealthy.tcp_failures must be at most 254")
end

Expand Down
21 changes: 10 additions & 11 deletions t/report_xrpc_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ qq{
statuses = { 500 },
failures = 2,
},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
},
},
})
Expand Down Expand Up @@ -110,7 +110,7 @@ qq{
failures = 3,

},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
},
},
})
Expand Down Expand Up @@ -171,7 +171,7 @@ qq{
tcp_failures = 2,
failures = 3,
},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
}
},

Expand Down Expand Up @@ -231,7 +231,7 @@ qq{
tcp_failures = 2,
failures = 0,
},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
},
},
})
Expand Down Expand Up @@ -289,7 +289,7 @@ qq{
interval = 999, -- we don't want active checks
failures = 3,
},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
},
},

Expand Down Expand Up @@ -363,7 +363,7 @@ qq{
statuses = { 501 },
failures = 2,
},
handler = function(node, conf)end
xrpc_handler = function(node, conf)end
},
},

Expand Down Expand Up @@ -407,8 +407,7 @@ event: target status '(127.0.0.1:2119)' from 'false' to 'true'



=== TEST 7: start xrpc healthcheck with active.unhealthy.failures == 4 and active.health.successes == 2
--- ONLY
=== TEST 7: start xrpc healthcheck with active.unhealthy.failures == 2 and active.health.successes == 2
--- http_config eval
qq{
$::HttpConfig
Expand Down Expand Up @@ -459,7 +458,7 @@ qq{
interval = 0.5, -- we don't want active checks
failures = 2,
},
handler = function(node, conf)
xrpc_handler = function(node, conf)
local http = require('resty.http')
local httpc = http.new()
local res, err = httpc:request_uri("http://127.0.0.1:2119/status", {
Expand All @@ -478,9 +477,9 @@ qq{
checker:add_target("127.0.0.1", 2119, nil, true)
ngx.sleep(0.5)
ngx.say(checker:get_target_status("127.0.0.1", 2119, nil)) -- true
ngx.sleep(2.0)
ngx.sleep(3.1)
ngx.say(checker:get_target_status("127.0.0.1", 2119, nil)) -- false
ngx.sleep(4.0)
ngx.sleep(4.2)
ngx.say(checker:get_target_status("127.0.0.1", 2119, nil)) -- true
}
}
Expand Down

0 comments on commit 0ba9414

Please sign in to comment.