Skip to content

Commit

Permalink
schema_registry: 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 fed63f3 commit fa4619e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/v/pandaproxy/api/api-doc/schema_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,18 @@
}
}
}
},
"/status/ready": {
"get": {
"summary": "Health check",
"operationId": "schema_registry_status_ready",
"responses": {
"200": {
"description": "Success"
},
"503": {
"description": "Service Unavailable"
}
}
}
}
7 changes: 7 additions & 0 deletions src/v/pandaproxy/schema_registry/handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,11 @@ compatibility_subject_version(server::request_t rq, server::reply_t rp) {
co_return rp;
}

ss::future<server::reply_t>
status_ready(server::request_t rq, server::reply_t rp) {
co_await rq.service().writer().read_sync();
rp.rep->set_status(ss::httpd::reply::status_type::ok);
co_return rp;
}

} // namespace pandaproxy::schema_registry
3 changes: 3 additions & 0 deletions src/v/pandaproxy/schema_registry/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ ss::future<ctx_server<service>::reply_t> delete_subject_version(
ss::future<ctx_server<service>::reply_t> compatibility_subject_version(
ctx_server<service>::request_t rq, ctx_server<service>::reply_t rp);

ss::future<ctx_server<service>::reply_t> status_ready(
ctx_server<service>::request_t rq, ctx_server<service>::reply_t rp);

} // namespace pandaproxy::schema_registry
4 changes: 4 additions & 0 deletions src/v/pandaproxy/schema_registry/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ server::routes_t get_schema_registry_routes(ss::gate& gate, one_shot& es) {
ss::httpd::schema_registry_json::compatibility_subject_version,
wrap(gate, es, compatibility_subject_version)});

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

return routes;
}

Expand Down

0 comments on commit fa4619e

Please sign in to comment.