Search in sources :

Example 1 with ServerProbe

use of org.wildfly.extension.health.ServerProbe in project wildfly by wildfly.

the class MicroProfileHealthReporterService method start.

@Override
public void start(StartContext context) {
    // MicroProfile Health supports the mp.health.disable-default-procedures to let users disable any vendor procedures
    final boolean defaultServerProceduresDisabled = ConfigProvider.getConfig().getOptionalValue("mp.health.disable-default-procedures", Boolean.class).orElse(false);
    // MicroProfile Health supports the mp.health.default.readiness.empty.response to let users specify default empty readiness responses
    final String defaultReadinessEmptyResponse = ConfigProvider.getConfig().getOptionalValue("mp.health.default.readiness.empty.response", String.class).orElse("DOWN");
    // MicroProfile Health supports the mp.health.default.startup.empty.response to let users specify default empty startup responses
    final String defaultStartupEmptyResponse = ConfigProvider.getConfig().getOptionalValue("mp.health.default.startup.empty.response", String.class).orElse("DOWN");
    healthReporter = new MicroProfileHealthReporter(emptyLivenessChecksStatus, emptyReadinessChecksStatus, emptyStartupChecksStatus, defaultServerProceduresDisabled, defaultReadinessEmptyResponse, defaultStartupEmptyResponse);
    if (!defaultServerProceduresDisabled) {
        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        for (ServerProbe serverProbe : serverProbesService.get().getServerProbes()) {
            healthReporter.addServerReadinessCheck(wrap(serverProbe), tccl);
        }
    }
    HealthCheckResponse.setResponseProvider(new ResponseProvider());
}
Also used : ServerProbe(org.wildfly.extension.health.ServerProbe) ResponseProvider(io.smallrye.health.ResponseProvider)

Example 2 with ServerProbe

use of org.wildfly.extension.health.ServerProbe in project wildfly by wildfly.

the class MicroProfileHealthReporterService method wrap.

static HealthCheck wrap(ServerProbe delegate) {
    return new HealthCheck() {

        @Override
        public HealthCheckResponse call() {
            ServerProbe.Outcome outcome = delegate.getOutcome();
            HealthCheckResponseBuilder check = HealthCheckResponse.named(delegate.getName()).status(outcome.isSuccess());
            if (outcome.getData().isDefined()) {
                for (Property property : outcome.getData().asPropertyList()) {
                    check.withData(property.getName(), property.getValue().asString());
                }
            }
            return check.build();
        }
    };
}
Also used : ServerProbe(org.wildfly.extension.health.ServerProbe) HealthCheckResponseBuilder(org.eclipse.microprofile.health.HealthCheckResponseBuilder) HealthCheck(org.eclipse.microprofile.health.HealthCheck) Property(org.jboss.dmr.Property)

Aggregations

ServerProbe (org.wildfly.extension.health.ServerProbe)2 ResponseProvider (io.smallrye.health.ResponseProvider)1 HealthCheck (org.eclipse.microprofile.health.HealthCheck)1 HealthCheckResponseBuilder (org.eclipse.microprofile.health.HealthCheckResponseBuilder)1 Property (org.jboss.dmr.Property)1