platformstate

package
v1.141.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package platformstate reports what the platform depends on and how its connections stand (#1898): dependency_up per dependency, connections by the state their last call found them in, the persona count, how long ago each search source last finished indexing, and mcp_platform_config_info. Before it every one of these was pull-only, answered by an admin route somebody had to think to open.

The probes run off the scrape path. A scrape reads the last result and, when that result is older than the probe interval, starts one refresh in the background, so a dependency that hangs costs a goroutine and never a scrape. Each replica probes for itself: dependency_up answers whether THIS replica reaches the dependency.

Nothing here gates readiness. /readyz reports the process state alone, so an upstream outage never takes every replica out of a load balancer at once, including the routes that do not need that upstream.

Index

Constants

View Source
const (
	// DefaultInterval is how old a result may be before a scrape refreshes it.
	DefaultInterval = time.Minute
	// DefaultProbeTimeout bounds one dependency probe.
	DefaultProbeTimeout = 5 * time.Second
)

Defaults for the probe cadence.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	OIDC, APIKeys, OAuth, Browser bool
	// Issuer is the OIDC issuer, probed for dependency_up{dependency="idp"}.
	Issuer string
}

Auth is which authentication methods the deployment configures.

type Deps

type Deps struct {
	// DB is the platform database, nil without one. It is pinged, and the
	// index-job history it holds is read for the search-index ages.
	DB *sql.DB
	// Dependencies maps a dependency name (observability.Dependency*) to its
	// probe. A dependency this deployment does not configure is absent.
	Dependencies map[string]Pinger
	// Toolkits is the toolkit registry whose connections are counted by the
	// state their last call found them in.
	Toolkits *registry.Registry
	// Personas is the persona registry counted.
	Personas *persona.Registry
	// Interval and ProbeTimeout override the defaults when positive.
	Interval     time.Duration
	ProbeTimeout time.Duration
}

Deps is what the sampler reads.

type PingFunc

type PingFunc func(ctx context.Context) error

PingFunc adapts a function to Pinger.

func (PingFunc) Ping

func (f PingFunc) Ping(ctx context.Context) error

Ping calls f.

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger is a dependency that can say whether it answers.

type Sampler

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

Sampler holds the last probe results and refreshes them.

func New

func New(deps Deps) *Sampler

New returns a sampler over deps. It has probed nothing until the first Refresh or scrape.

func Start

func Start(m *observability.Metrics, deps Deps) *Sampler

Start registers s as m's platform-state sampler and starts its first refresh. Nil-safe on m: with metrics off nothing is probed.

func Wire

func Wire(m *observability.Metrics, src Sources) *Sampler

Wire records mcp_platform_config_info and starts the sampler over src's dependencies. Nil-safe on m.

func (*Sampler) Refresh

func (s *Sampler) Refresh(ctx context.Context)

Refresh pings every dependency and reads the index ages, in parallel, and stores the result.

func (*Sampler) Sample

Sample is the scrape-time read: the last result, with the persona count and the connection states read now (both in memory), and a background refresh started when the result is stale.

type Sources

type Sources struct {
	DB       *sql.DB
	Semantic semantic.Provider
	Query    query.Provider
	// Objects is the portal's blob store and Bucket its bucket; Objects is nil
	// in database-only mode.
	Objects    any
	Bucket     string
	Auth       Auth
	Thumbnails thumbworker.Config
	Toolkits   *registry.Registry
	Personas   *persona.Registry
	Tracer     *observability.Tracer
	// Interval is server.state_probe_interval; zero is DefaultInterval.
	Interval time.Duration
}

Sources is what the platform hands the seam.

Jump to

Keyboard shortcuts

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