Documentation
¶
Overview ¶
Package providerhealth caches per-provider HealthChecker results so dashboards can render workspace state without hammering the underlying control planes (docker socket, k8s API server, nomad agent) on every request.
The cache is in-memory, populated by a periodic poller that runs HealthChecker.HealthCheck on every registered provider. Consumers (studio handlers, the workload-health aggregator, admin views) read from the cache via Get / Snapshot — both are O(1) and lock-free in the read path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds the most recent health status per provider name. Polled by Run; consumers read with Get / Snapshot.
func NewCache ¶
NewCache wires a cache against the given registry. The cache is empty until Run() ticks at least once. Consumers calling Get before the first tick get ok=false — the studio handlers treat that as "unknown" and degrade the badge gracefully.
func (*Cache) CheckNow ¶
CheckNow runs a one-shot sweep ignoring the schedule. Useful after a provider re-registers or a manual "refresh" action.
func (*Cache) Get ¶
Get returns the last-known status for a provider. ok=false when the cache hasn't seen this provider yet (cold cache, or provider just registered).
func (*Cache) Run ¶
Run blocks until ctx is cancelled. Does an upfront sweep so the cache populates promptly, then ticks at the poll interval. Spawn this in a background goroutine — never call it inline: the sweep can block on a slow provider HealthCheck (k8s when the cluster is unreachable, for instance), and we don't want startup to depend on that.
type Config ¶
type Config struct {
// PollInterval is how often the cache re-checks every provider.
// Default 30s — provider-control-plane health changes slowly,
// so this trades a small staleness window for tiny load.
PollInterval time.Duration
// CheckTimeout caps each individual HealthCheck call. Set
// shorter than PollInterval so a hung provider doesn't block
// the whole sweep. Default 5s.
CheckTimeout time.Duration
}
Config tunes the cache.