Documentation
¶
Overview ¶
Package reachability tracks probe-backed reachability independently from managed-server lifecycle and admission state.
Index ¶
- Constants
- type Attempt
- type Depth
- type Disposition
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Remove(name string) error
- func (m *Manager) Start(parent context.Context, target Target, interval time.Duration) error
- func (m *Manager) StartWithProbe(parent context.Context, target Target, interval time.Duration, probe Probe) error
- func (m *Manager) Stop(name string) error
- func (m *Manager) Wait()
- type Outcome
- type Probe
- type ProbeEvidence
- type ProbeResult
- type Reachability
- type State
- type Store
- func (s *Store) Get(serverName string) (Reachability, bool)
- func (s *Store) RecordDefinitiveFailure(serverName string, depth Depth, attemptedAt time.Time, cause string) Reachability
- func (s *Store) RecordProbe(serverName string, result ProbeResult) Reachability
- func (s *Store) Remove(serverName string)
- func (s *Store) StartProbe(serverName string, depth Depth, attemptedAt time.Time) Reachability
- type Target
- type VersionSelector
Constants ¶
const ( ProtocolVersion2024_11_05 = "2024-11-05" ProtocolVersion2025_03_26 = "2025-03-26" ProtocolVersion2025_06_18 = "2025-06-18" ProtocolVersion2025_11_25 = "2025-11-25" DefaultProbeInterval = 30 * time.Second // EndToEndProbeIntervalMultiple keeps the admission-consuming probe rare // relative to the free listener probe. EndToEndProbeIntervalMultiple = 10 )
const ( // FailureThreshold prevents transient failures from reporting a server as // unreachable. This is the daemon-wide established probe convention. FailureThreshold = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attempt ¶ added in v1.5.14
type Attempt struct {
Disposition Disposition
Err error
}
Attempt is one probe attempt's completion: its disposition plus the cause detail. Err carries the reason for failures and inconclusive attempts and is ignored for successes.
type Disposition ¶ added in v1.5.14
type Disposition string
Disposition is how one probe attempt completed. Success and failure are completed outcomes at the probe's depth. Inconclusive means the attempt ended without proving either — for example an admission denial that answered before the backend was touched — so it must change no completed evidence at that depth.
const ( DispositionSuccess Disposition = "success" DispositionFailure Disposition = "failure" DispositionInconclusive Disposition = "inconclusive" )
func DispositionFromError ¶ added in v1.5.14
func DispositionFromError(err error) Disposition
DispositionFromError maps a completed traffic check to a disposition: an error is a failure, no error is a success. It never reports inconclusive; only a probe owner that observes an inconclusive condition may.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns one cancellable probe worker per server.
func NewManager ¶
func NewManager(store *Store, selector *VersionSelector, logger ...*slog.Logger) *Manager
func (*Manager) Close ¶
func (m *Manager) Close()
Close cancels and joins every worker. It is safe to call repeatedly.
func (*Manager) Remove ¶
Remove stops the worker before deleting evidence, ensuring an in-flight result cannot be written after the server has left the registry.
func (*Manager) StartWithProbe ¶
type Probe ¶
Probe is the version-independent seam for reachability mechanisms. An implementation reports the disposition of its attempt; only a mechanism that observes why its attempt proved nothing (for example an admission denial answered before the backend was touched) may report inconclusive.
type ProbeEvidence ¶
type ProbeEvidence struct {
Depth Depth `json:"depth"`
LastProbeAttempt time.Time `json:"last_probe_attempt"`
LastOutcomeAt time.Time `json:"last_outcome_at,omitempty"`
LastProbeOutcome Outcome `json:"last_probe_outcome"`
LastProbeError string `json:"last_probe_error,omitempty"`
ConsecutiveFailures int `json:"consecutive_failures"`
}
ProbeEvidence is the latest result and failure streak for one probe depth. LastProbeAttempt is when the most recent attempt ran, whatever it proved; attempts that prove nothing and attempts still in flight move only that timestamp. LastOutcomeAt is when the standing completed outcome was recorded, and only a completed success or failure may move it, so an inconclusive or in-flight attempt can never redate completed evidence. LastProbeError is deliberately a bounded, single-line string so it can be rendered directly by administrative surfaces without exposing an error object or control characters.
type ProbeResult ¶
type ProbeResult struct {
Depth Depth
AttemptedAt time.Time
Disposition Disposition
Error string
}
ProbeResult records one probe attempt's completion. A zero AttemptedAt is replaced by the store's current time. Error is ignored except for failures. An inconclusive disposition joins the started probe but records no completed outcome: the prior outcome, error, failure streak, and depth state all stand.
type Reachability ¶
type Reachability struct {
State State `json:"state"`
Evidence map[Depth]ProbeEvidence `json:"evidence,omitempty"`
}
Reachability is a point-in-time value returned by Store. Evidence is kept per depth so a shallow result cannot erase a deeper result. Callers receive an independent copy of the evidence map.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a concurrency-safe, in-memory reachability store keyed by server name. It has no admission or lifecycle behavior.
func (*Store) Get ¶
func (s *Store) Get(serverName string) (Reachability, bool)
Get returns the current reachability for serverName. An unseen server returns an unprobed value and false.
func (*Store) RecordDefinitiveFailure ¶
func (s *Store) RecordDefinitiveFailure(serverName string, depth Depth, attemptedAt time.Time, cause string) Reachability
RecordDefinitiveFailure records a failure that is known to be terminal rather than transient, marking the depth unreachable immediately without waiting for FailureThreshold consecutive failures.
FailureThreshold exists to stop a flaky probe from reporting a healthy server as broken. That reasoning does not apply to a failure whose cause is already proven, such as a proxy listener that failed to register: there is no listener to become reachable again, so requiring two further confirmations would report a known-broken server as healthy for the duration.
Callers must use this only when the failure is structurally terminal. A probe that merely failed to connect is transient and belongs in RecordProbe.
func (*Store) RecordProbe ¶
func (s *Store) RecordProbe(serverName string, result ProbeResult) Reachability
RecordProbe records a completed probe attempt and returns the resulting value. Failures become unreachable only after FailureThreshold consecutive failures at the same depth. A success resets that depth's failure streak. An inconclusive attempt consumes the started probe and preserves every piece of completed evidence at that depth.
func (*Store) StartProbe ¶
StartProbe marks a server as probing at depth and records the attempt time. It is safe for multiple probe workers to start concurrently.
type Target ¶
Target identifies the local Vision listener to probe. ProtocolVersion is the negotiated MCP revision; keeping it on the target makes the mechanism selection explicit when a later revision needs a different probe.
type VersionSelector ¶
type VersionSelector struct {
// contains filtered or unexported fields
}
VersionSelector maps negotiated MCP revisions to probe mechanisms. It is intentionally explicit: protocol revisions that remove initialize/sessions must not silently inherit a mechanism designed for an older revision.
func NewVersionSelector ¶
func NewVersionSelector(listener Probe, endToEnd ...Probe) *VersionSelector
func (*VersionSelector) Select ¶
func (s *VersionSelector) Select(protocolVersion string) (Probe, error)
Select returns the mechanism for a negotiated revision. An empty revision uses the latest revision supported by the current SDK, which is the only safe default before a server has completed negotiation.
func (*VersionSelector) SelectEndToEnd ¶
func (s *VersionSelector) SelectEndToEnd(protocolVersion string) (Probe, error)