health

package
v0.44.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package health is the platform's built-in health (ADR-0215): the storage prober, which reads a sentinel key of the KV engine and the blob store on a period and keeps each result in memory, and the dependency checker the worker-node local API answers GET /health/dependencies with.

Index

Constants

View Source
const ReasonStorageUnreachable = "StorageUnreachable"

ReasonStorageUnreachable is the Ready reason of a KVStore or Bucket whose storage probe fails (ADR-0215 Decision 7).

Variables

This section is empty.

Functions

func NewChecker

func NewChecker(d CheckerDeps) local.DependencyChecker

NewChecker builds the dependency check of ADR-0215 Decision 3.

func StoreStatus

func StoreStatus(cur v1.Status, r Result, gen int64) v1.Status

StoreStatus is cur, a KVStore's or Bucket's status, at generation gen after its storage probe gave r: phase Ready with Ready True while the probe passes, else phase Degraded with Ready False StorageUnreachable and the probe error.

Types

type Binding added in v0.36.1

type Binding struct {
	Kind    string
	Aliases func(fn *v1.Function) []string
	Check   func(ctx context.Context, caller local.Ref, alias string) *local.DependencyReport
}

Binding is one kind of a Function's bindings the dependency check reads: Aliases lists them in spec order, and Check checks one, returning its failure or nil. A kind with no constructor below fills the fields itself.

func Blob added in v0.36.1

func Blob(rc ReadChecker, p *Prober) Binding

Blob checks a Function's blob bindings as KV checks its KV ones, against the blob probe.

func KV added in v0.36.1

func KV(rc ReadChecker, p *Prober) Binding

KV checks a Function's KV bindings: resolve and read authorization, then the KV probe's last result.

Links checks a Function's links: the resolver's link-as-grant, link::invoke when authz is set, and that the target exists in st and is not Failed.

func SQL added in v0.36.1

func SQL(rc ReadChecker) Binding

SQL checks a Function's SQL bindings: resolve, read authorization and a Ready engine (ADR-0233 Decision 8); it has no prober target.

func Secret added in v0.42.0

func Secret(rc ReadChecker) Binding

Secret checks a Function's Secret bindings (ADR-0321 Decision 4): each bound Secret's secret::read as the caller. It reads no Secret and has no prober target, so a missing Secret passes and the start check answers for it.

type CheckerDeps

type CheckerDeps struct {
	Store    local.FunctionStore
	Bindings []Binding
}

CheckerDeps are what the dependency check reads: the metastore that holds the caller, and the kinds of bindings it checks in list order, each a provider's own (ADR-0308).

type Probe

type Probe func(ctx context.Context) error

Probe reads one storage once; an error is the storage being unreachable.

func BlobProbe

func BlobProbe(b blob.Bucket) Probe

BlobProbe asks b whether SentinelKey exists: either answer is healthy.

func KVProbe

func KVProbe(kv kvstore.KV) Probe

KVProbe reads SentinelKey from kv: found or missing is healthy.

type Prober

type Prober struct {
	// contains filtered or unexported fields
}

Prober probes each target once per interval, each probe bounded by timeout, and keeps the results in memory (ADR-0215 Decision 6). It writes nothing.

func NewProber

func NewProber(c clock.Clock, interval, timeout time.Duration, probes map[Target]Probe, logger *slog.Logger) (*Prober, error)

NewProber builds a prober over probes. interval and timeout are positive and timeout is less than interval.

func (*Prober) OnChange

func (p *Prober) OnChange(fn func(Target, Result))

OnChange registers fn, called after a probe whose result's Healthy differs from the target's previous one.

func (*Prober) Result

func (p *Prober) Result(t Target) Result

Result is target t's latest result; a target with no probe, or not probed yet, is healthy.

func (*Prober) Start

func (p *Prober) Start(ctx context.Context)

Start probes each target once before it returns, then once per interval until ctx is done.

type ReadChecker

type ReadChecker interface {
	CheckRead(ctx context.Context, ns v1.NamespaceName, fn v1.ObjectName, alias string) error
}

ReadChecker resolves a caller's binding alias and authorizes a read on it, with no storage call: the KV, blob and SQL Facades' CheckRead.

type Result

type Result struct {
	Healthy bool
	Message string
	Since   time.Time
}

Result is a target's latest probe outcome: Message holds the probe error while it fails, and Since is when Healthy last changed (the first probe for a result that never changed).

type Target

type Target string

Target names a storage the prober reads.

const (
	TargetKV   Target = "kv"
	TargetBlob Target = "blob"
	// SentinelKey is the key a probe reads. A namespace is a DNS label, so no data key starts with ".".
	SentinelKey = ".funcd-health"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL