Skip to content

Commit 22ea547

Browse files
support specific route too
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
1 parent 67c0997 commit 22ea547

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

apisix/control/v1.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ function _M.get_health_checker()
243243
values = get_services()
244244
elseif src_type == "upstreams" then
245245
values = get_upstreams()
246+
elseif src_type == "stream_routes" then
247+
values = get_stream_routes()
246248
else
247249
return 400, {error_msg = str_format("invalid src type %s", src_type)}
248250
end

t/stream-node/control-api-healthcheck.t

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,25 @@ __DATA__
127127
return ngx.exit(503)
128128
end
129129
ngx.say(dkjson.encode(healthcheck_data))
130+
131+
-- healthcheck of stream route
132+
local healthcheck, _, body = t("/v1/healthcheck/stream_routes/1", ngx.HTTP_GET)
133+
if healthcheck >= 300 then
134+
ngx.status = healthcheck
135+
return
136+
end
137+
138+
local healthcheck_data, err = core.json.decode(body)
139+
if not healthcheck_data then
140+
ngx.log(ngx.ERR, "failed to decode healthcheck data: ", err)
141+
return ngx.exit(503)
142+
end
143+
ngx.say(dkjson.encode(healthcheck_data))
130144
}
131145
}
132146
--- timeout: 5
133147
--- request
134148
GET /test
135149
--- response_body
136150
[{"name":"/apisix/stream_routes/1","nodes":[{"counter":{"http_failure":0,"success":0,"tcp_failure":0,"timeout_failure":0},"hostname":"127.0.0.1","ip":"127.0.0.1","port":1995,"status":"healthy"}],"type":"tcp"}]
151+
{"name":"/apisix/stream_routes/1","nodes":[{"counter":{"http_failure":0,"success":0,"tcp_failure":0,"timeout_failure":0},"hostname":"127.0.0.1","ip":"127.0.0.1","port":1995,"status":"healthy"}],"type":"tcp"}

0 commit comments

Comments
 (0)