Interface HealthChecker
- All Known Subinterfaces:
ListenableHealthChecker
- All Known Implementing Classes:
SettableHealthChecker
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Determines whether the
Server
is healthy. All registered HealthChecker
s must return
true
for the Server
to be considered healthy.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if and only if theServer
is healthy.static HealthChecker
of(Supplier<? extends CompletionStage<HealthCheckStatus>> healthChecker, Duration fallbackTtl)
Returns a newly createdHealthChecker
that invokes the specified health checker repetitively on an arbitraryEventExecutor
fromCommonPools.workerGroup()
.static HealthChecker
of(Supplier<? extends CompletionStage<HealthCheckStatus>> healthChecker, Duration fallbackTtl, EventExecutor eventExecutor)
Returns a newly createdHealthChecker
that invokes the specified health checker repetitively on the specifiedEventExecutor
.
-
Method Details
-
of
@UnstableApi static HealthChecker of(Supplier<? extends CompletionStage<HealthCheckStatus>> healthChecker, Duration fallbackTtl)Returns a newly createdHealthChecker
that invokes the specified health checker repetitively on an arbitraryEventExecutor
fromCommonPools.workerGroup()
.- Parameters:
healthChecker
- ASupplier
that performs a health check asynchronously and returns a future that will complete with aHealthCheckStatus
.HealthCheckStatus.ttlMillis()
determines the delay before the next health check. If the future completed exceptionally, the specifiedfallbackTtl
will be used instead to determine the delay.Supplier
should avoid returning null or throwing exception. TheCompletionStage
fromSupplier
should avoid completing with null result or failing.fallbackTtl
- The amount of delay between each health check if the previous health check failed unexpectedly so it's not possible to determine how long we have to wait until the next health check.- See Also:
of(Supplier, Duration, EventExecutor)
-
of
@UnstableApi static HealthChecker of(Supplier<? extends CompletionStage<HealthCheckStatus>> healthChecker, Duration fallbackTtl, EventExecutor eventExecutor)Returns a newly createdHealthChecker
that invokes the specified health checker repetitively on the specifiedEventExecutor
.- Parameters:
healthChecker
- ASupplier
that performs a health check asynchronously and returns a future that will complete with aHealthCheckStatus
.HealthCheckStatus.ttlMillis()
determines the delay before the next health check. If the future completed exceptionally, the specifiedfallbackTtl
will be used instead to determine the delay.Supplier
should avoid returning null or throwing exception. TheCompletionStage
fromSupplier
should avoid completing with null result or failing.fallbackTtl
- The amount of delay between each health check if the previous health check failed unexpectedly so it's not possible to determine how long we have to wait until the next health check.eventExecutor
- TheEventExecutor
that will invoke the specifiedhealthChecker
.
-
isHealthy
boolean isHealthy()Returnstrue
if and only if theServer
is healthy.
-