Skip to content

Commit

Permalink
pp/rest: Add a health check
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope committed Dec 22, 2022
1 parent f238a8e commit 2f979d1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/v/pandaproxy/api/api-doc/rest.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,4 +547,18 @@
}
}
}
},
"/status/ready": {
"get": {
"summary": "Health check",
"operationId": "http_rest_status_ready",
"responses": {
"200": {
"description": "Success"
},
"503": {
"description": "Service Unavailable"
}
}
}
}
11 changes: 11 additions & 0 deletions src/v/pandaproxy/rest/handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,15 @@ post_consumer_offsets(server::request_t rq, server::reply_t rp) {
});
}

ss::future<proxy::server::reply_t>
status_ready(proxy::server::request_t rq, proxy::server::reply_t rp) {
auto make_metadata_req = []() {
return kafka::metadata_request{.list_all_topics = false};
};

auto res = co_await rq.dispatch(make_metadata_req);
rp.rep->set_status(ss::httpd::reply::status_type::ok);
co_return rp;
}

} // namespace pandaproxy::rest
3 changes: 3 additions & 0 deletions src/v/pandaproxy/rest/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ get_consumer_offsets(proxy::server::request_t rq, proxy::server::reply_t rp);
ss::future<proxy::server::reply_t>
post_consumer_offsets(proxy::server::request_t rq, proxy::server::reply_t rp);

ss::future<proxy::server::reply_t>
status_ready(proxy::server::request_t rq, proxy::server::reply_t rp);

} // namespace pandaproxy::rest
4 changes: 4 additions & 0 deletions src/v/pandaproxy/rest/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ server::routes_t get_proxy_routes(ss::gate& gate, one_shot& es) {
ss::httpd::rest_json::post_consumer_offsets,
wrap(gate, es, post_consumer_offsets)});

routes.routes.emplace_back(server::route_t{
ss::httpd::rest_json::http_rest_status_ready,
wrap(gate, es, status_ready)});

return routes;
}

Expand Down

0 comments on commit 2f979d1

Please sign in to comment.