io.smallrye.health.SmallRyeHealth Java Examples

The following examples show how to use io.smallrye.health.SmallRyeHealth. 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 vote down vote up
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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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);
}
 
Example #5
Source File: SmallRyeHealthGroupHandler.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) {
    return reporter.getHealthGroups();
}
 
Example #6
Source File: SmallRyeHealthHandler.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) {
    return reporter.getHealth();
}
 
Example #7
Source File: SmallRyeLivenessHandler.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) {
    return reporter.getLiveness();
}
 
Example #8
Source File: SmallRyeIndividualHealthGroupHandler.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) {
    String group = ctx.normalisedPath().substring(ctx.normalisedPath().lastIndexOf("/") + 1);
    return reporter.getHealthGroup(group);
}
 
Example #9
Source File: SmallRyeReadinessHandler.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext routingContext) {
    return reporter.getReadiness();
}
 
Example #10
Source File: SmallRyeHealthHandlerBase.java    From quarkus with Apache License 2.0 votes vote down vote up
protected abstract SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext routingContext);