-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make health checks addable via SPI
- Loading branch information
Showing
10 changed files
with
174 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.neonbee.health; | ||
|
||
import java.util.List; | ||
|
||
import io.vertx.core.Vertx; | ||
|
||
/** | ||
* This interface can be used to provide additional health checks to NeonBee. If you implement this interface, NeonBee | ||
* discovers the implementing class and registers all health checks of the list to NeonBee's health check registry. | ||
*/ | ||
@FunctionalInterface | ||
public interface HealthCheckProvider { | ||
|
||
/** | ||
* Provide custom health checks that will be registered to NeonBee's health check registry. | ||
* | ||
* @param vertx the current Vert.x instance | ||
* @return a succeeded future if registering was successful. A failed Future, otherwise. | ||
*/ | ||
List<AbstractHealthCheck> get(Vertx vertx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.neonbee.health; | ||
|
||
import java.util.function.Function; | ||
|
||
import io.neonbee.NeonBee; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Promise; | ||
import io.vertx.ext.healthchecks.Status; | ||
|
||
public class DummyHealthCheck extends AbstractHealthCheck { | ||
/** | ||
* Name of the health check. | ||
*/ | ||
public static final String DUMMY_ID = "dummy"; | ||
|
||
/** | ||
* Constructs an instance of {@link AbstractHealthCheck}. | ||
* | ||
* @param neonBee the current NeonBee instance | ||
*/ | ||
public DummyHealthCheck(NeonBee neonBee) { | ||
super(neonBee); | ||
} | ||
|
||
@Override | ||
public Function<NeonBee, Handler<Promise<Status>>> createProcedure() { | ||
return nb -> promise -> promise.complete(new Status().setOK()); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return DUMMY_ID; | ||
} | ||
|
||
@Override | ||
public boolean isGlobal() { | ||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/java/io/neonbee/health/DummyHealthCheckProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.neonbee.health; | ||
|
||
import java.util.List; | ||
|
||
import io.neonbee.NeonBee; | ||
import io.vertx.core.Vertx; | ||
|
||
public class DummyHealthCheckProvider implements HealthCheckProvider { | ||
@Override | ||
public List<AbstractHealthCheck> get(Vertx vertx) { | ||
return List.of(new DummyHealthCheck(NeonBee.get(vertx))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters