diff --git a/lib/resty/healthcheck.lua b/lib/resty/healthcheck.lua index 77390a6..940b0c4 100644 --- a/lib/resty/healthcheck.lua +++ b/lib/resty/healthcheck.lua @@ -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, @@ -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 @@ -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 diff --git a/t/report_xrpc_status.t b/t/report_xrpc_status.t index 9fac115..e3df50d 100644 --- a/t/report_xrpc_status.t +++ b/t/report_xrpc_status.t @@ -51,7 +51,7 @@ qq{ statuses = { 500 }, failures = 2, }, - handler = function(node, conf)end + xrpc_handler = function(node, conf)end }, }, }) @@ -110,7 +110,7 @@ qq{ failures = 3, }, - handler = function(node, conf)end + xrpc_handler = function(node, conf)end }, }, }) @@ -171,7 +171,7 @@ qq{ tcp_failures = 2, failures = 3, }, - handler = function(node, conf)end + xrpc_handler = function(node, conf)end } }, @@ -231,7 +231,7 @@ qq{ tcp_failures = 2, failures = 0, }, - handler = function(node, conf)end + xrpc_handler = function(node, conf)end }, }, }) @@ -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 }, }, @@ -363,7 +363,7 @@ qq{ statuses = { 501 }, failures = 2, }, - handler = function(node, conf)end + xrpc_handler = function(node, conf)end }, }, @@ -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 @@ -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", { @@ -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 } }