Class Health.Builder
java.lang.Object
com.jsgalactic.axiom.observability.Health.Builder
- Enclosing class:
Health
Collects checks before
build().-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the health service.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.liveness(String name, HealthCheck check) Adds a check that decides whether the process should be restarted.liveness(String name, HealthCheck check, Duration timeout) Adds a liveness check with its own timeout.readiness(String name, HealthCheck check) Adds a check that decides whether the instance should receive traffic.readiness(String name, HealthCheck check, Duration timeout) Adds a readiness check with its own timeout.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.startup(String name, HealthCheck check, Duration timeout) Adds a startup check with its own timeout.Sets how long one probe waits for its checks; all checks of a probe run concurrently.
-
Method Details
-
liveness
Adds a check that decides whether the process should be restarted.- Parameters:
name- letters, digits and_ . -, 1 to 64 characters, unique among liveness checkscheck- the condition- Returns:
- this builder
- Throws:
IllegalArgumentException- for an invalid or duplicate name, or too many checks
-
liveness
Adds a liveness check with its own timeout.- Parameters:
name- letters, digits and_ . -, 1 to 64 characters, unique among liveness checkscheck- the conditiontimeout- how long this check may run, positive, at mostHealth.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
Adds a check that decides whether the instance should receive traffic.- Parameters:
name- letters, digits and_ . -, 1 to 64 characters, unique among readiness checkscheck- the condition- Returns:
- this builder
- Throws:
IllegalArgumentException- for an invalid or duplicate name, or too many checks
-
readiness
Adds a readiness check with its own timeout.- Parameters:
name- letters, digits and_ . -, 1 to 64 characters, unique among readiness checkscheck- the conditiontimeout- how long this check may run, positive, at mostHealth.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
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 checkscheck- the condition- Returns:
- this builder
- Throws:
IllegalArgumentException- for an invalid or duplicate name, or too many checks
-
startup
Adds a startup check with its own timeout.- Parameters:
name- letters, digits and_ . -, 1 to 64 characters, unique among startup checkscheck- the conditiontimeout- how long this check may run, positive, at mostHealth.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
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 mostHealth.MAX_CACHE- Returns:
- this builder
- Throws:
IllegalArgumentException- for a negative or too long interval
-
timeout
Sets how long one probe waits for its checks; all checks of a probe run concurrently.- Parameters:
timeout- positive, at mostHealth.MAX_TIMEOUT; the default isHealth.DEFAULT_TIMEOUT- Returns:
- this builder
- Throws:
IllegalArgumentException- for an invalid timeout
-
build
Builds the health service.- Returns:
- a new instance
-