io.github.snower.jaslock.spring.boot.actuate.SlockHealthIndicator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaslock-spring-boot Show documentation
Show all versions of jaslock-spring-boot Show documentation
High-performance distributed sync service and atomic DB. Provides good multi-core support through lock queues, high-performance asynchronous binary network protocols. Can be used for spikes, synchronization, event notification, concurrency control. https://github.com/snower/slock
The newest version!
package io.github.snower.jaslock.spring.boot.actuate;
import io.github.snower.jaslock.exceptions.SlockException;
import io.github.snower.jaslock.spring.boot.SlockTemplate;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
public class SlockHealthIndicator implements HealthIndicator {
private final SlockTemplate slockTemplate;
public SlockHealthIndicator(SlockTemplate slockTemplate) {
this.slockTemplate = slockTemplate;
}
@Override
public Health health() {
try {
if (slockTemplate.getClient().ping()) {
return Health.up().build();
}
return Health.down().build();
} catch (SlockException e) {
return Health.down()
.status(new Status(e.getClass().getName(), e.toString()))
.build();
}
}
}