Class HealthCheckServiceBuilder

java.lang.Object
com.linecorp.armeria.server.healthcheck.HealthCheckServiceBuilder

public final class HealthCheckServiceBuilder
extends Object
  • Method Details

    • checkers

      public HealthCheckServiceBuilder checkers​(HealthChecker... healthCheckers)
      Adds the specified HealthCheckers that determine the healthiness of the Server.
      Returns:
      this
    • checkers

      public HealthCheckServiceBuilder checkers​(Iterable<? extends HealthChecker> healthCheckers)
      Adds the specified HealthCheckers that determine the healthiness of the Server.
      Returns:
      this
    • healthyResponse

      public HealthCheckServiceBuilder healthyResponse​(AggregatedHttpResponse healthyResponse)
      Sets the AggregatedHttpResponse to send when the Service 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

      public HealthCheckServiceBuilder unhealthyResponse​(AggregatedHttpResponse unhealthyResponse)
      Sets the AggregatedHttpResponse to send when the Service 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

      public HealthCheckServiceBuilder longPolling​(Duration maxLongPollingTimeout)
      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. Specify 0 to disable long-polling support.
      Returns:
      this
      See Also:
      longPolling(Duration, double, Duration)
    • longPolling

      public HealthCheckServiceBuilder longPolling​(long maxLongPollingTimeoutMillis)
      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. Specify 0 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. Specify 0 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. Specify 0 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

      public HealthCheckServiceBuilder updatable​(boolean updatable)
      Specifies whether the healthiness of the Server can be updated by sending a PUT, POST or PATCH request to the HealthCheckService. This feature is disabled by default. If enabled, a JSON object which has a boolean property named "healthy" can be sent using a PUT or POST request. A JSON patch in a PATCH request is also accepted. It is recommended to employ some authorization mechanism such as AuthService when enabling this feature.
      Returns:
      this
      See Also:
      updatable(HealthCheckUpdateHandler)
    • updatable

      public HealthCheckServiceBuilder updatable​(HealthCheckUpdateHandler updateHandler)
      Specifies a HealthCheckUpdateHandler which handles other HTTP methods than HEAD and GET which updates the healthiness of the Server. This feature is disabled by default. It is recommended to employ some authorization mechanism such as AuthService when enabling this feature.
      Parameters:
      updateHandler - The HealthCheckUpdateHandler which handles PUT, POST or PATCH requests and tells if the Server needs to be marked as healthy or unhealthy.
      See Also:
      updatable(boolean)
    • build

      public HealthCheckService build()
      Returns a newly created HealthCheckService built from the properties specified so far.