Interface HealthCheckHandler
-
- All Superinterfaces:
Handler<RoutingContext>
public interface HealthCheckHandler extends Handler<RoutingContext>
A Vert.x Web handler on which you register health check procedure. It computes the outcome status (`UP` or `DOWN`) . When the handler process an HTTP request, it computes the global outcome and build a HTTP response as follows:- 204 - status is `UP` but no procedures installed (no payload)
- 200 - status is `UP`, the payload contains the result of the installed procedures
- 503 - status is `DOWN`, the payload contains the result of the installed procedures
- 500 - status is `DOWN`, the payload contains the result of the installed procedures, one of the procedure has failed
- Author:
- Clement Escoffier
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static HealthCheckHandler
create(Vertx vertx)
Creates an instance of the default implementation of theHealthCheckHandler
.static HealthCheckHandler
create(Vertx vertx, AuthenticationProvider provider)
Creates an instance of the default implementation of theHealthCheckHandler
.static HealthCheckHandler
createWithHealthChecks(HealthChecks hc)
Creates an instance of the default implementation of theHealthCheckHandler
.static HealthCheckHandler
createWithHealthChecks(HealthChecks hc, AuthenticationProvider provider)
Creates an instance of the default implementation of theHealthCheckHandler
.HealthCheckHandler
register(String name, long timeout, Handler<Promise<Status>> procedure)
Registers a health check procedure.HealthCheckHandler
register(String name, Handler<Promise<Status>> procedure)
Registers a health check procedure.HealthCheckHandler
resultMapper(java.util.function.Function<CheckResult,Future<CheckResult>> resultMapper)
Sets a function which will be invoked before theCheckResult
gets written to clients.HealthCheckHandler
unregister(String name)
Unregisters a procedure.
-
-
-
Method Detail
-
create
static HealthCheckHandler create(Vertx vertx, AuthenticationProvider provider)
Creates an instance of the default implementation of theHealthCheckHandler
. This function creates a new instance ofHealthChecks
.- Parameters:
vertx
- the Vert.x instance, must not benull
provider
- the Authentication provider used to authenticate the HTTP request- Returns:
- the created instance
-
create
static HealthCheckHandler create(Vertx vertx)
Creates an instance of the default implementation of theHealthCheckHandler
. This function creates a new instance ofHealthChecks
.- Parameters:
vertx
- the Vert.x instance, must not benull
- Returns:
- the created instance
-
createWithHealthChecks
static HealthCheckHandler createWithHealthChecks(HealthChecks hc, AuthenticationProvider provider)
Creates an instance of the default implementation of theHealthCheckHandler
.- Parameters:
hc
- the health checks object to use, must not benull
- Returns:
- the created instance
-
createWithHealthChecks
static HealthCheckHandler createWithHealthChecks(HealthChecks hc)
Creates an instance of the default implementation of theHealthCheckHandler
.- Parameters:
hc
- the health checks object to use- Returns:
- the created instance
-
register
HealthCheckHandler register(String name, Handler<Promise<Status>> procedure)
Registers a health check procedure.The procedure is a
Handler
taking aPromise
ofStatus
as parameter. Procedures are asynchronous, and must complete or fail the givenPromise
. If the future object is failed, the procedure outcome is considered as `DOWN`. If the future is completed without any object, the procedure outcome is considered as `UP`. If the future is completed with a (not-null)Status
, the procedure outcome is the received status.This method uses a 1s timeout. To configure the timeout use
register(String, long, Handler)
.- Parameters:
name
- the name of the procedure, must not benull
or emptyprocedure
- the procedure, must not benull
- Returns:
- the current
HealthCheckHandler
-
register
HealthCheckHandler register(String name, long timeout, Handler<Promise<Status>> procedure)
Registers a health check procedure.The procedure is a
Handler
taking aPromise
ofStatus
as parameter. Procedures are asynchronous, and must complete or fail the givenPromise
. If the future object is failed, the procedure outcome is considered as `DOWN`. If the future is completed without any object, the procedure outcome is considered as `UP`. If the future is completed with a (not-null)Status
, the procedure outcome is the received status.- Parameters:
name
- the name of the procedure, must not benull
or emptytimeout
- the procedure timeoutprocedure
- the procedure, must not benull
- Returns:
- the current
HealthCheckHandler
-
unregister
HealthCheckHandler unregister(String name)
Unregisters a procedure.- Parameters:
name
- the name of the procedure- Returns:
- the current
HealthCheckHandler
-
resultMapper
HealthCheckHandler resultMapper(java.util.function.Function<CheckResult,Future<CheckResult>> resultMapper)
Sets a function which will be invoked before theCheckResult
gets written to clients.- Parameters:
resultMapper
- theFunction
used to manipulate theCheckResult
,null
means no result mapper function enabled.- Returns:
- the current
HealthCheckHandler
-
-