Documentation
¶
Overview ¶
Package readiness verifies that a plugin has applied its own boot-time migrations (contract:plugin.boot-migrations v1, ADR 0010).
Purpose: the CLI never applies plugin SQL. A plugin applies its migrations when it boots (sdk/go/migrate) and serves {"migrations":{"applied":n, "expected":m}} in its /health JSON. Install and update flows call Wait to block, bounded, until applied == expected; `nself doctor` calls Probe once.
Inputs: the plugin name (for messages), its /health URL and a timeout. Outputs: nil when ready, otherwise a *errs.CLIError naming the plugin: E118 when the wait ended with applied < expected (or the plugin never answered), E119 when /health has no valid migrations field. A cancelled caller context returns the context error, not E118. Constraints: every wait is bounded (a non-positive timeout is an error); HTTP goes through internal/httptimeout; nothing here touches the database.
Index ¶
Constants ¶
const ( // DefaultTimeout bounds Wait when NSELF_PLUGIN_READY_TIMEOUT is unset. DefaultTimeout = 120 * time.Second // EnvTimeout overrides DefaultTimeout (integer seconds, or a Go duration such as 3m). EnvTimeout = "NSELF_PLUGIN_READY_TIMEOUT" )
Variables ¶
This section is empty.
Functions ¶
func IsUnreachable ¶
IsUnreachable reports whether err is a "plugin did not answer /health" error from Probe (as opposed to an E119 contract violation).
func TimeoutFromEnv ¶
TimeoutFromEnv returns the wait bound: EnvTimeout when set, else DefaultTimeout. An unparseable or non-positive value is an error, never a silent default.
func Wait ¶
func Wait(ctx context.Context, plugin, healthURL string, timeout time.Duration, opts ...Option) error
Wait polls healthURL until the plugin reports applied == expected, for at most timeout. It returns E119 at once when /health lacks the migrations field, and E118 (naming the plugin and both numbers) when the timeout ends first. Callers read the bound with TimeoutFromEnv.
Types ¶
type Option ¶
type Option func(*config)
Option tunes Wait.
func WithClient ¶
WithClient sets the HTTP client (default httptimeout.WithTimeout(5 s)).
func WithInterval ¶
WithInterval sets the poll interval (default 2 s).
type Progress ¶
Progress is the migrations status a plugin serves in /health.