Ankusa.Health.Check behaviour (ankusa v0.7.0)

Copy Markdown View Source

One thing GET /ready asks about (Ankusa.Health).

A check says whether it applies?/1 to this node's config (a node with no store has no store check, a threshold left nil switches its check off), whether a failure of it makes the node unready (gates?/1), and run/1s itself. all/0 is the registry, in the order the body lists them:

run/1 answers :ok, {:failing, reason} or {:draining, reason}, the reason an atom from a fixed set per check (it reaches the /ready body, so it never carries an error term). A check must not hold a request longer than a readiness probe waits: bound every call it makes.

Summary

Callbacks

Whether this node's config has the check run at all.

Whether a check that is not :ok makes the node unready (503).

The key the check's state has in the /ready body.

Functions

Every check, in body order.

Run check. A check that raises, exits or throws is failing with reason :error: readiness never crashes the probe, and a check that cannot answer must not read as healthy.

Types

result()

@type result() :: :ok | {:failing, atom()} | {:draining, atom()}

Callbacks

applies?(t)

@callback applies?(Ankusa.Config.t()) :: boolean()

Whether this node's config has the check run at all.

gates?(t)

@callback gates?(Ankusa.Config.t()) :: boolean()

Whether a check that is not :ok makes the node unready (503).

name()

@callback name() :: atom()

The key the check's state has in the /ready body.

run(t)

@callback run(Ankusa.Config.t()) :: result()

Functions

all()

@spec all() :: [module()]

Every check, in body order.

run(check, config)

@spec run(module(), Ankusa.Config.t()) :: result()

Run check. A check that raises, exits or throws is failing with reason :error: readiness never crashes the probe, and a check that cannot answer must not read as healthy.