Skip to content

Commit

Permalink
Use the /readyz endpoint to simplify ready check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexh-sauce committed Oct 23, 2024
1 parent 1b76926 commit 991382c
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -785,23 +785,19 @@ public void run() {

private void pollEndpoint() {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(String.format("http://localhost:%d/status", port)))
.uri(URI.create(String.format("http://localhost:%d/readyz", port)))
.GET()
.build();

try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

this.LOGGER.info("Got http response", response.statusCode());

if (response.statusCode() == 200) {
this.apiResponse = true;
String responseBody = response.body();
JSONObject jsonObject = new JSONObject(responseBody);
if (jsonObject.has("status") && "connected".equals(jsonObject.getString("status"))) {
this.LOGGER.info("Got connected status");
semaphore.release();
}
this.LOGGER.info("Got connected status");
semaphore.release();
} else if (response.statusCode() == 503) {
this.apiResponse = true;
}
} catch ( Exception e ) {
if ( this.apiResponse ) {
Expand All @@ -812,7 +808,7 @@ private void pollEndpoint() {
}
}

this.LOGGER.info("No API response yet");
this.LOGGER.trace("No API response yet");
}
}
}

0 comments on commit 991382c

Please sign in to comment.