Class HealthCheckService

java.lang.Object
com.linecorp.armeria.server.healthcheck.HealthCheckService
All Implemented Interfaces:
Unwrappable, HttpService, Service<HttpRequest,HttpResponse>, TransientHttpService, TransientService<HttpRequest,HttpResponse>

public final class HealthCheckService extends Object implements TransientHttpService
An HttpService that responds with HTTP status "200 OK" if the server is healthy and can accept requests and HTTP status "503 Service Not Available" if the server is unhealthy and cannot accept requests. The default behavior is to respond healthy after the server is started and unhealthy after it started to stop.

Long-polling support

A client that sends health check requests to this service can send a long-polling request to get notified immediately when a Server becomes healthy or unhealthy, rather than sending health check requests periodically.

To wait until a Server becomes unhealthy, i.e. wait for the failure, send an HTTP request with two additional headers:

  • If-None-Match: "healthy"
  • Prefer: wait=<seconds>
    • e.g. Prefer: wait=60

To wait until a Server becomes healthy, i.e. wait for the recovery, send an HTTP request with two additional headers:

  • If-None-Match: "unhealthy"
  • Prefer: wait=<seconds>

The Server will wait up to the amount of seconds specified in the "Prefer" header and respond with "200 OK", "503 Service Unavailable" or "304 Not Modified". "304 Not Modifies" signifies that the healthiness of the Server did not change. Once the response is received, the client is supposed to send a new long-polling request to continue watching the healthiness of the Server.

All health check responses will contain a "armeria-lphc" header whose value is the maximum allowed value of the "Prefer: wait=<seconds>" header. 0 means long polling has been disabled. "lphc" stands for long-polling health check.

See Also: