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

io.github.snower.jaslock.spring.boot.actuate.SlockHealthIndicator Maven / Gradle / Ivy

Go to download

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();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy