Documentation
¶
Overview ¶
Package depcheck is the fleet's dependency-health registry. Services register the upstream(s) they depend on (html-proxy, js-proxy, rate-coordinator, the keystore, …) and depcheck probes them on every /health request. The probed status is folded into the /health JSON so operators (and the catalog UI) can see at a glance which transitive dependencies are degraded — not just whether the service's own process is up.
Convention: registration happens at service startup; probes run on every /health call (no background polling, no caching). Probes are expected to be cheap — a HEAD request, an in-process check, a single TCP dial. Anything heavier should cache its own result.
Sample wiring:
deps := depcheck.New()
deps.Register("html-proxy", func(ctx context.Context) error {
return client.ProbeHTMLProxy(ctx)
})
server.Run("go_my_service", version, Handler,
server.WithDependencies(deps))
/health response then becomes:
{
"status": "degraded",
"service": "go_my_service",
"version": "1.4.0",
"dependencies": [
{"name":"html-proxy","ok":true,"latency_ms":42,"checked_at":"..."},
{"name":"keystore","ok":false,"latency_ms":3001,"error":"context deadline exceeded","checked_at":"..."}
]
}
status is "healthy" if all probes pass, "degraded" if any fail. HTTP status code stays 200 either way — operators tail the JSON, not the status code — so liveness probes don't flap when a soft dep blips.
Package depcheck provides a registry of named health probes whose results are included in the /health endpoint JSON.
Services register probes (e.g. ping a database, check a file) via Registry.Register. The server calls Snapshot on every /health request and surfaces {status:"degraded"} if any probe fails (HTTP stays 200).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Observer ¶
type Observer interface {
ObserveDep(Event)
}
Observer receives one event per probed dependency per Snapshot call. Implementations MUST NOT block — callbacks run inline on /health. The canonical implementation lives in go-common/promx.
depcheck deliberately defines the contract here rather than importing a metrics library: depcheck keeps zero metric-stack deps.
type Probe ¶
Probe is the cheap, idempotent check registered for an upstream. Return nil on success; any non-nil error is reported verbatim.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the fan-out registry of probes.
func New ¶
func New() *Registry
New creates an empty registry with a 2s per-probe timeout. Probes run in parallel on Snapshot(); 2s is the cap per probe, total Snapshot latency is therefore ~max(probe-latency) capped at 2s.
func (*Registry) Register ¶
Register adds a named probe. Names should be short and stable ("html-proxy", "keystore"); they appear verbatim in /health JSON and in operator dashboards. Re-registering the same name appends a second entry — callers should register each dep exactly once.
func (*Registry) SetObserver ¶
WithObserver returns a Registry option-equivalent. Apply it after New() via SetObserver — depcheck.New() doesn't take variadic options today, and we'd rather not break callers.