Class Health.Builder

java.lang.Object
com.jsgalactic.axiom.observability.Health.Builder
Enclosing class:
Health

public static final class Health.Builder extends Object
Collects checks before build().
  • Method Details

    • liveness

      public Health.Builder liveness(String name, HealthCheck check)
      Adds a check that decides whether the process should be restarted.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among liveness checks
      check - the condition
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, or too many checks
    • liveness

      public Health.Builder liveness(String name, HealthCheck check, Duration timeout)
      Adds a liveness check with its own timeout.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among liveness checks
      check - the condition
      timeout - how long this check may run, positive, at most Health.MAX_TIMEOUT; replaces the probe timeout for it
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, an invalid timeout, or too many checks
    • readiness

      public Health.Builder readiness(String name, HealthCheck check)
      Adds a check that decides whether the instance should receive traffic.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among readiness checks
      check - the condition
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, or too many checks
    • readiness

      public Health.Builder readiness(String name, HealthCheck check, Duration timeout)
      Adds a readiness check with its own timeout.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among readiness checks
      check - the condition
      timeout - how long this check may run, positive, at most Health.MAX_TIMEOUT; replaces the probe timeout for it
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, an invalid timeout, or too many checks
    • startup

      public Health.Builder startup(String name, HealthCheck check)
      Adds a check that must pass once before the instance counts as started, such as a cache warm-up or a completed migration. The startup probe runs these checks until all pass at the same time, then stays UP.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among startup checks
      check - the condition
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, or too many checks
    • startup

      public Health.Builder startup(String name, HealthCheck check, Duration timeout)
      Adds a startup check with its own timeout.
      Parameters:
      name - letters, digits and _ . -, 1 to 64 characters, unique among startup checks
      check - the condition
      timeout - how long this check may run, positive, at most Health.MAX_TIMEOUT; replaces the probe timeout for it
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid or duplicate name, an invalid timeout, or too many checks
    • cacheFor

      public Health.Builder cacheFor(Duration ttl)
      Keeps the result of each check for a while, so that a check polled by several probers, or often, runs at most once per interval. Healthy, unhealthy and timed-out results are all kept; a check that is still running from an earlier probe is not cached. Draining and a stopped application are never cached. The default is no caching.
      Parameters:
      ttl - zero for none, or at most Health.MAX_CACHE
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for a negative or too long interval
    • timeout

      public Health.Builder timeout(Duration timeout)
      Sets how long one probe waits for its checks; all checks of a probe run concurrently.
      Parameters:
      timeout - positive, at most Health.MAX_TIMEOUT; the default is Health.DEFAULT_TIMEOUT
      Returns:
      this builder
      Throws:
      IllegalArgumentException - for an invalid timeout
    • build

      public Health build()
      Builds the health service.
      Returns:
      a new instance