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 probe whose Status is toggled by external code via Set. Safe for concurrent use.
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.
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 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 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()