io.github.sinri.drydock.common.health.HealthMonitorMixin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of DryDock Show documentation
Show all versions of DryDock Show documentation
Prototype Library for Keel Based Java Projects.
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();
});
}
}