-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
Description
Thank you for providing such a great project. I encountered some problems while using it.
Test according to the test case, the following code:
location = /t {
content_by_lua_block {
local we = require "resty.worker.events"
assert(we.configure{ shm = "my_worker_events", interval = 0.1 })
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
shm_name = "test_shm",
checks = {
active = {
http_path = "/status",
healthy = {
interval = 999, -- we don't want active checks
successes = 1,
},
unhealthy = {
interval = 999, -- we don't want active checks
tcp_failures = 1,
http_failures = 1,
}
},
passive = {
healthy = {
successes = 1,
},
unhealthy = {
tcp_failures = 1,
http_failures = 1,
}
}
}
})
ngx.sleep(0.1) -- wait for initial timers to run once
local ok, err = checker:add_target("127.0.0.1", 8088, nil, true)
ngx.say(checker:get_target_status("127.0.0.1", 8088)) -- true
checker:report_tcp_failure("127.0.0.1", 8088)
ngx.say(checker:get_target_status("127.0.0.1", 8088)) -- false
checker:report_success("127.0.0.1", 8088)
ngx.say(checker:get_target_status("127.0.0.1", 8088)) -- true
}
}
The result of execution is:
curl http://127.0.0.1:8085/t
false
false
true
Why can't I reproduce the same results as your test case?
In other words, after executing checker:add_target, the result of executing checker:get_target_status for the first time is false.
I can confirm that my corresponding interface exists: as follows
curl -I http://127.0.0.1:8088/status
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Mon, 04 Mar 2024 15:53:43 GMT
Content-Length: 15
Please tell me if there is anything wrong here;Thx
the openresty version of mine is 1.13.