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 ¶
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 Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler holds the last probe results and refreshes them.
func New ¶
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 ¶
Refresh pings every dependency and reads the index ages, in parallel, and stores the result.
func (*Sampler) Sample ¶
func (s *Sampler) Sample(_ context.Context) observability.PlatformStateSample
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.