org.zodiac.actuate.application.internal.AppAvailabilityReadinessHealthChecker Maven / Gradle / Ivy
package org.zodiac.actuate.application.internal;
import org.springframework.boot.actuate.health.Health;
import org.zodiac.actuate.health.checker.ReadinessHealthChecker;
import org.zodiac.core.application.availability.AppAvailability;
import org.zodiac.core.application.availability.ReadinessState;
public class AppAvailabilityReadinessHealthChecker implements ReadinessHealthChecker {
public static final String NAME = "app-availability-readiness";
private AppAvailability availability;
public AppAvailabilityReadinessHealthChecker(AppAvailability availability) {
this.availability = availability;
}
@Override
public Health isHealthy() {
ReadinessState readinessState = availability.getReadinessState();
if (readinessState == ReadinessState.ACCEPTING_TRAFFIC) {
return Health.up().withDetail("info", "The application service instance is set to receive traffic.")
.build();
} else if (readinessState == ReadinessState.REFUSING_TRAFFIC) {
return Health.down()
.withDetail("info", "The application service instance is set to refuse to receive traffic.").build();
}
return Health.up().build();
}
@Override
public String getName() {
return NAME;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy