Documentation
¶
Overview ¶
Package probe defines the core probe abstractions: a status enum, the Probe interface, function adapters and composition helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asyncer ¶
type Asyncer interface {
Go(fn func())
Wait()
}
Asyncer schedules concurrent work and waits for completion. A fresh Asyncer is obtained per check via AsyncerFactory.
type AsyncerFactory ¶
type AsyncerFactory func() Asyncer
AsyncerFactory builds a fresh Asyncer per use.
func PoolFactory ¶
func PoolFactory(maxConcurrent int) AsyncerFactory
PoolFactory returns an AsyncerFactory yielding fresh PoolAsyncer instances.
func SyncFactory ¶
func SyncFactory() AsyncerFactory
SyncFactory returns an AsyncerFactory yielding SyncAsyncer.
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool is a toggleable probe. Its zero value is down. Status and reason are stored atomically and may be read or updated concurrently.
type Composite ¶
type Composite struct {
// contains filtered or unexported fields
}
Composite runs multiple probes concurrently and aggregates their results.
func New ¶
func New(mode Mode, opts ...CompositeOption) *Composite
New builds a Composite with the given mode and options.
func (*Composite) Check ¶
Check runs all child probes concurrently and aggregates by Mode. Empty composites report StatusUp.
func (*Composite) CheckResult ¶ added in v1.2.0
CheckResult aggregates observations in declaration order, including names and reasons of failing children. A successful Any has no failure reason.
type CompositeOption ¶
type CompositeOption func(*Composite)
CompositeOption configures a Composite at construction time.
func WithAsyncer ¶
func WithAsyncer(f AsyncerFactory) CompositeOption
WithAsyncer overrides the default AsyncerFactory used to run child probes.
type Detailed ¶ added in v1.2.0
Detailed is an optional extension of Probe. Evaluate calls CheckResult instead of Check, so status and reason always describe the same observation.
type Named ¶
type Named struct {
Probe
// contains filtered or unexported fields
}
Named attaches a human-readable name to an underlying Probe.
type PoolAsyncer ¶
type PoolAsyncer struct {
// contains filtered or unexported fields
}
PoolAsyncer fans out to goroutines bounded by an optional semaphore. maxConcurrent <= 0 means unbounded.
func NewPoolAsyncer ¶
func NewPoolAsyncer(maxConcurrent int) *PoolAsyncer
func (*PoolAsyncer) Go ¶
func (p *PoolAsyncer) Go(f func())
func (*PoolAsyncer) Wait ¶
func (p *PoolAsyncer) Wait()
type Probe ¶
Probe is anything that can report a health Status given a context.
Implementations MUST honor ctx cancellation: long-running checks (network I/O, external dependencies) must abort and return promptly when ctx is canceled. Callers such as runner.Runner and the HTTP/gRPC transports spawn a goroutine per check and rely on ctx to bound its lifetime — a probe that ignores ctx will leak a goroutine on every timeout.
The returned Status should reflect the most recent observation. Returning StatusUnknown is appropriate only when no determination could be made (e.g. ctx canceled before any work).
type Result ¶ added in v1.2.0
Result is one observation. Reason explains a non-Up result; it is empty after recovery. Reasons can be exposed by HTTP handlers and reporters.
func Evaluate ¶ added in v1.2.0
Evaluate performs exactly one check, preserving details where available.
func (Result) Normalized ¶ added in v1.2.0
Normalized clears obsolete reasons on healthy results.
type ResultFunc ¶ added in v1.2.0
ResultFunc adapts a detailed check without breaking the Probe contract.
func (ResultFunc) CheckResult ¶ added in v1.2.0
func (f ResultFunc) CheckResult(ctx context.Context) Result
type Status ¶
type Status uint8
Status represents the outcome of a probe check.
Zero value is StatusUnknown so a never-checked probe is distinguishable from one that has been checked and reported StatusUp.
type SyncAsyncer ¶
type SyncAsyncer struct{}
SyncAsyncer runs each func inline. Wait is a no-op.
func (SyncAsyncer) Go ¶
func (SyncAsyncer) Go(f func())
func (SyncAsyncer) Wait ¶
func (SyncAsyncer) Wait()