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

io.github.sinri.drydock.common.health.HealthMonitorMixin Maven / Gradle / Ivy

The newest version!
package io.github.sinri.drydock.common.health;

import io.github.sinri.drydock.common.CommonUnit;
import io.github.sinri.drydock.common.logging.issue.HealthMonitorIssueRecord;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
import io.vertx.core.ThreadingModel;

public interface HealthMonitorMixin extends CommonUnit {
    default HealthMonitor buildHealthMonitor() {
        return new HealthMonitorWithIssueRecorder(generateIssueRecorder(HealthMonitorIssueRecord.TopicHealthMonitor, HealthMonitorIssueRecord::new));
    }

    default Future loadHealthMonitor() {
        return Future.succeededFuture(buildHealthMonitor())
                .compose(healthMonitor -> {
                    if (healthMonitor == null) return Future.succeededFuture();
                    return healthMonitor.deployMe(new DeploymentOptions().setThreadingModel(ThreadingModel.WORKER));
                })
                .onFailure(throwable -> {
                    getLogger().exception(throwable, "Failed to deploy HealthMonitor");
                })
                .compose(deploymentId -> {
                    getLogger().info("Deployed HealthMonitor: " + deploymentId);
                    return Future.succeededFuture();
                });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy