Skip to main content

CheckConfig

Each check is a CheckConfig entry in the checks array on the root config:

AdapterResult

Each adapter.check() resolves to:
  • status: "ok" | "degraded" | "fail".
  • error: Optional Error or string (included in the serialized check unless output.exposeError is false).
  • metadata: Optional object merged into the check result.
Thrown errors from adapter.check() are treated as fail, with the error message captured internally and exposed in full HTTP output when output.exposeError is true; status-only output omits errors.

Deadlines and cancellation

Healthzkit calls check(context?: CheckContext), where context.signal is an AbortSignal that aborts when the check deadline expires. Existing zero-argument adapters continue to work. You can pass the signal to an API that supports cancellation:
A deadline bounds the health response; it does not forcibly cancel driver work. Adapters must use the signal with an API that supports cancellation. The HTTP adapter forwards it to fetch, AWS SDK v3 S3 and DynamoDB pass it as abortSignal, AWS SDK v2 aborts the individual request, and Elasticsearch passes it as a request signal. These paths leave shared clients open. Within one kit, concurrent requests for the same check share one operation, including liveness and readiness requests. If it times out, later requests fail immediately until the underlying operation settles. A late result cannot turn that timeout into a success. After settlement, checks without an active scheduled cache start a fresh operation on the next request. Scheduled checks keep serving the cached result until a later interval refreshes it. Other checks and other kit instances run independently. Stopping or restarting scheduling does not release pending adapter work.

Driver timeouts

Configure driver timeouts as well as the Healthzkit deadline. Include connection establishment, pool acquisition, commands, and retries in your budget. A connection timeout alone does not bound a query on an established connection. Prefer driver budgets shorter than the check deadline so the driver can settle and release any borrowed resources before the health response expires. The following audit covers the operations used by the official adapters. “No” means the adapter does not forward the context signal, even if a newer driver offers other cancellation APIs. Configure these options on your injected client, or via the adapter’s driver configuration where exposed. Verify names and units against your installed driver version. Metadata hooks receive the client but do not receive CheckContext. Give their additional operations driver timeouts too. Canceling a supported health operation does not cancel unrelated work or forcibly close a caller-owned client. If a driver ignores cancellation or never settles, the check continues returning its timeout without launching more underlying work. Use scheduling to control normal check frequency; it does not replace driver timeouts.

Official adapters

This monorepo publishes optional packages that return a HealthAdapter for runtime resources and common infrastructure: queues, databases, storage, search, and HTTP endpoints. For anything else, use a custom adapter.check() implementation.

Runtime

Queues

Databases

Storage

  • S3 — @healthzkit/s3
  • MinIO — @healthzkit/minio

HTTP

Adapter cleanup

HealthAdapter can optionally implement dispose(): void | Promise<void>. await kit.close() calls it once per distinct adapter after pending checks settle. Release only resources your adapter owns, and make cleanup idempotent if it can also be called directly. Check-only adapters remain compatible. See Shutdown and disposal for terminal-close behavior and cleanup errors.