All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.actuate.health.checker.ReadinessHealthIndicator Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.actuate.health.checker;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.util.CollectionUtils;

public class ReadinessHealthIndicator extends AbstractHealthIndicator {

    private ReadinessHealthCheckerProcessor processor;
    private List afterProcessors;
    private AtomicBoolean healthCallbackStatus = new AtomicBoolean(true);

    public ReadinessHealthIndicator(ReadinessHealthCheckerProcessor readinessHealthCheckProcessor,
        List afterProcessors) {
        this.processor = readinessHealthCheckProcessor;
        this.afterProcessors = afterProcessors;
    }

    public boolean getHealthCallbackStatus() {
        return healthCallbackStatus.get();
    }

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        Health health = processor.healthCheck();
        if (!CollectionUtils.isEmpty(afterProcessors)) {
            for (AfterReadinessHealthCheckerProcessor p : afterProcessors) {
                healthCallbackStatus.getAndSet(p.healthCheckCallback(health.getDetails()));
            }
        }
        builder.status(health.getStatus()).withDetails(health.getDetails());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy