![JAR search and dependency download from the Maven repository](/logo.png)
com.github.kagkarlsson.scheduler.boot.actuator.DbSchedulerHealthIndicator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of db-scheduler-spring-boot-starter Show documentation
Show all versions of db-scheduler-spring-boot-starter Show documentation
A starter for Spring Boot that will configure db-scheduler
/**
* Copyright (C) Gustav Karlsson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.kagkarlsson.scheduler.boot.actuator;
import com.github.kagkarlsson.scheduler.Scheduler;
import com.github.kagkarlsson.scheduler.SchedulerState;
import java.util.Objects;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
public class DbSchedulerHealthIndicator implements HealthIndicator {
private final SchedulerState state;
public DbSchedulerHealthIndicator(Scheduler scheduler) {
this.state = Objects.requireNonNull(scheduler).getSchedulerState();
}
@Override
public Health health() {
if (state.isStarted() && !state.isShuttingDown()) {
return Health.up()
.withDetail("state", "started")
.build();
} else if (state.isStarted() && state.isShuttingDown()) {
return Health.outOfService()
.withDetail("state", "shutting_down")
.build();
} else if (!state.isStarted() && !state.isShuttingDown()) {
return Health.down()
.withDetail("state", "not_started")
.build();
} else {
return Health.down().build();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy