
reload
Package reload owns SIGHUP-driven configuration reload. The coordinator runs a two-phase Check / Apply pass over a sequence of hooks, swaps the atomic config on success, and reports full / partial / validation / load outcomes via ReloadResult.
Index
type Coordinator
Coordinator owns the SIGHUP goroutine, the hook sequence, and the last-result snapshot. Construct it with New, then call Watch to start the signal listener. Shutdown stops the goroutine. LastResult is concurrent-safe.
func New
New returns a Coordinator with the given deps. Watch must be called to start observing SIGHUP. Deps is passed by pointer because it embeds a slog.LevelVar pointer and the runtime needs to mutate the underlying state through it.
func (*Coordinator) Generation
Generation returns the monotonic generation counter. Starts at 0; advances on every successful Apply pass (full or partial).
func (*Coordinator) LastResult
LastResult returns the most recent reload result, or nil if no reload has been attempted yet.
func (*Coordinator) Reload
Reload performs one full reload pass. Exposed so tests and admin surfaces can trigger a reload without sending a real signal. Returns the result of the pass; the same value is stored on the coordinator and reachable via LastResult.
func (*Coordinator) Shutdown
Shutdown stops the SIGHUP goroutine and waits for it to exit. Safe to call multiple times.
func (*Coordinator) Watch
Watch installs a SIGHUP handler and spawns the reload goroutine. The goroutine runs until Shutdown is called.
type Deps
Deps groups everything the coordinator mutates or reads on reload.
type Hook
Hook is the contract every reloadable subsystem implements. The coordinator runs Check on every hook first; any error aborts the pass before mutation. Apply then runs every hook, collecting per-hook outcomes. Apply errors mark the hook failed but do not abort the remaining hooks.
type HookOutcome
HookOutcome captures one hook’s contribution to a reload result.
type HookStatus
HookStatus describes the outcome of a single hook’s Apply call.
HookStatus values. Skipped covers “not configured / not registered” (e.g. UI handler when UI is disabled); Failed only fires when Apply returned a non-nil error.
type ReloadResult
ReloadResult is the aggregate report from a single reload pass. The coordinator stores the most recent result atomically; the admin API exposes it for operator inspection. Generation is monotonic and only advances on a successful Apply pass (FullSuccess or PartialApplied).
type ReloadStatus
ReloadStatus describes the overall outcome of a reload pass.
- FullSuccess: every hook returned Applied or Skipped.
- PartialApplied: at least one hook returned Failed, but the Check pass succeeded so the config was still swapped in.
- ValidationFailed: at least one hook’s Check returned an error; no Apply ran, no mutation happened, generation unchanged.
- LoadFailed: the YAML file failed to load or validate; no hooks ran, generation unchanged.
Generated by gomarkdoc