Class HealthCheckServiceBuilder
java.lang.Object
com.linecorp.armeria.server.healthcheck.HealthCheckServiceBuilder
- All Implemented Interfaces:
TransientServiceBuilder
Builds a
HealthCheckService
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newly createdHealthCheckService
built from the properties specified so far.checkers(HealthChecker... healthCheckers)
Adds the specifiedHealthChecker
s that determine the healthiness of theServer
.checkers(Iterable<? extends HealthChecker> healthCheckers)
Adds the specifiedHealthChecker
s that determine the healthiness of theServer
.healthyResponse(AggregatedHttpResponse healthyResponse)
Sets theAggregatedHttpResponse
to send when theService
is healthy.longPolling(long maxLongPollingTimeoutMillis)
Enables or disables long-polling support.longPolling(long maxLongPollingTimeoutMillis, double longPollingTimeoutJitterRate, long pingIntervalMillis)
Enables or disables long-polling support.longPolling(Duration maxLongPollingTimeout)
Enables or disables long-polling support.longPolling(Duration maxLongPollingTimeout, double longPollingTimeoutJitterRate, Duration pingInterval)
Enables or disables long-polling support.Disables setting healthy when theServer
starts.transientServiceOptions(TransientServiceOption... transientServiceOptions)
Enables the specifiedTransientServiceOption
s forTransientService
.transientServiceOptions(Iterable<TransientServiceOption> transientServiceOptions)
Enables the specifiedTransientServiceOption
s forTransientService
.unhealthyResponse(AggregatedHttpResponse unhealthyResponse)
Sets theAggregatedHttpResponse
to send when theService
is unhealthy.updatable(boolean updatable)
Specifies whether the healthiness of theServer
can be updated by sending aPUT
,POST
orPATCH
request to theHealthCheckService
.updatable(HealthCheckUpdateHandler updateHandler)
Specifies aHealthCheckUpdateHandler
which handles other HTTP methods thanHEAD
andGET
which updates the healthiness of theServer
.updateListener(HealthCheckUpdateListener updateListener)
Adds aHealthCheckUpdateListener
which is invoked when the healthiness of theServer
is updated.
-
Method Details
-
checkers
Adds the specifiedHealthChecker
s that determine the healthiness of theServer
.- Returns:
this
-
checkers
Adds the specifiedHealthChecker
s that determine the healthiness of theServer
.- Returns:
this
-
healthyResponse
Sets theAggregatedHttpResponse
to send when theService
is healthy. The following response is sent by default:HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 { "healthy": true }
- Returns:
this
-
unhealthyResponse
Sets theAggregatedHttpResponse
to send when theService
is unhealthy. The following response is sent by default:HTTP/1.1 503 Service Unavailable Content-Type: application/json; charset=utf-8 { "healthy": false }
- Returns:
this
-
longPolling
Enables or disables long-polling support. By default, long-polling support is enabled with the max timeout of 60 seconds and the jitter rate of 0.2.- Parameters:
maxLongPollingTimeout
- A positive maximum allowed timeout value which is specified by a client in the"prefer: wait=<n>"
request header. Specify0
to disable long-polling support.- Returns:
this
- See Also:
longPolling(Duration, double, Duration)
-
longPolling
Enables or disables long-polling support. By default, long-polling support is enabled with the max timeout of 60 seconds and the jitter rate of 0.2.- Parameters:
maxLongPollingTimeoutMillis
- A positive maximum allowed timeout value which is specified by a client in the"prefer: wait=<n>"
request header. Specify0
to disable long-polling support.- Returns:
this
- See Also:
longPolling(long, double, long)
-
longPolling
public HealthCheckServiceBuilder longPolling(Duration maxLongPollingTimeout, double longPollingTimeoutJitterRate, Duration pingInterval)Enables or disables long-polling support. By default, long-polling support is enabled with the max timeout of 60 seconds and the jitter rate of 0.2.- Parameters:
maxLongPollingTimeout
- A positive maximum allowed timeout value which is specified by a client in the"prefer: wait=<n>"
request header. Specify0
to disable long-polling support.longPollingTimeoutJitterRate
- The jitter rate which adds a random variation to the long-polling timeout specified in the"prefer: wait=<n>"
header.- Returns:
this
- See Also:
longPolling(Duration)
-
longPolling
public HealthCheckServiceBuilder longPolling(long maxLongPollingTimeoutMillis, double longPollingTimeoutJitterRate, long pingIntervalMillis)Enables or disables long-polling support. By default, long-polling support is enabled with the max timeout of 60 seconds and the jitter rate of 0.2.- Parameters:
maxLongPollingTimeoutMillis
- A positive maximum allowed timeout value which is specified by a client in the"prefer: wait=<n>"
request header. Specify0
to disable long-polling support.longPollingTimeoutJitterRate
- The jitter rate which adds a random variation to the long-polling timeout specified in the"prefer: wait=<n>"
header.- Returns:
this
- See Also:
longPolling(long)
-
updatable
Specifies whether the healthiness of theServer
can be updated by sending aPUT
,POST
orPATCH
request to theHealthCheckService
. This feature is disabled by default. If enabled, a JSON object which has a boolean property named"healthy"
can be sent using aPUT
orPOST
request. A JSON patch in aPATCH
request is also accepted. It is recommended to employ some authorization mechanism such asAuthService
when enabling this feature.- Returns:
this
- See Also:
updatable(HealthCheckUpdateHandler)
-
updatable
Specifies aHealthCheckUpdateHandler
which handles other HTTP methods thanHEAD
andGET
which updates the healthiness of theServer
. This feature is disabled by default. It is recommended to employ some authorization mechanism such asAuthService
when enabling this feature.- Parameters:
updateHandler
- TheHealthCheckUpdateHandler
which handlesPUT
,POST
orPATCH
requests and tells if theServer
needs to be marked as healthy or unhealthy.- See Also:
updatable(boolean)
-
updateListener
Adds aHealthCheckUpdateListener
which is invoked when the healthiness of theServer
is updated. -
startUnhealthy
Disables setting healthy when theServer
starts. This might be useful when you want to update the healthiness manually later via usingHealthCheckUpdateHandler
. Please note that it's set unhealthy when theServer
stops regardless. -
transientServiceOptions
public HealthCheckServiceBuilder transientServiceOptions(TransientServiceOption... transientServiceOptions)Description copied from interface:TransientServiceBuilder
Enables the specifiedTransientServiceOption
s forTransientService
. AllTransientServiceOption
s are disabled by default if unspecified.- Specified by:
transientServiceOptions
in interfaceTransientServiceBuilder
-
transientServiceOptions
public HealthCheckServiceBuilder transientServiceOptions(Iterable<TransientServiceOption> transientServiceOptions)Description copied from interface:TransientServiceBuilder
Enables the specifiedTransientServiceOption
s forTransientService
. AllTransientServiceOption
s are disabled by default if unspecified.- Specified by:
transientServiceOptions
in interfaceTransientServiceBuilder
-
build
Returns a newly createdHealthCheckService
built from the properties specified so far.
-