Java Code Examples for io.smallrye.health.SmallRyeHealth#isDown()
The following examples show how to use
io.smallrye.health.SmallRyeHealth#isDown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SmallRyeHealthHandlerBase.java From quarkus with Apache License 2.0 | 5 votes |
private void doHandle(RoutingContext ctx) { SmallRyeHealthReporter reporter = Arc.container().instance(SmallRyeHealthReporter.class).get(); SmallRyeHealth health = getHealth(reporter, ctx); HttpServerResponse resp = ctx.response(); if (health.isDown()) { resp.setStatusCode(503); } resp.headers().set(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8"); try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { reporter.reportHealth(outputStream, health); resp.end(Buffer.buffer(outputStream.toByteArray())); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example 2
Source File: SmallRyeReadinessServlet.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Handle the GET request. * * @param request the HTTP servlet request. * @param response the HTTP servlet response. * @throws IOException when an I/O error occurs. */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { SmallRyeHealth health = reporter.getReadiness(); if (health.isDown()) { response.setStatus(503); } response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); reporter.reportHealth(response.getOutputStream(), health); }
Example 3
Source File: SmallRyeLivenessServlet.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Handle the GET request. * * @param request the HTTP servlet request. * @param response the HTTP servlet response. * @throws IOException when an I/O error occurs. */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { SmallRyeHealth health = reporter.getLiveness(); if (health.isDown()) { response.setStatus(503); } response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); reporter.reportHealth(response.getOutputStream(), health); }
Example 4
Source File: SmallRyeHealthServlet.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Handle the GET request. * * @param request the HTTP servlet request. * @param response the HTTP servlet response. * @throws IOException when an I/O error occurs. */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { SmallRyeHealth health = reporter.getHealth(); if (health.isDown()) { response.setStatus(503); } response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); reporter.reportHealth(response.getOutputStream(), health); }