Documentation
¶
Overview ¶
Package health provides utilities for monitoring the healthiness of an application.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndMonitor ¶
type AndMonitor []Monitor
AndMonitor is a collection of [Monitor]s which follows the logical AND (&&) semantics for determining its own healthy/unhealthy state.
In the case of an error it will fail fast.
func And ¶
func And(ms ...Monitor) AndMonitor
And is a simple helper for initializing a AndMonitor in a more functional style.
Example ¶
var a Binary var b Binary and := And(&a, &b) healthy, _ := and.Healthy(context.Background()) fmt.Println(healthy) a.MarkHealthy() healthy, _ = and.Healthy(context.Background()) fmt.Println(healthy) b.MarkHealthy() healthy, _ = and.Healthy(context.Background()) fmt.Println(healthy)
Output: false false true
type Binary ¶
type Binary struct {
// contains filtered or unexported fields
}
Binary is a Monitor which simply has 2 states: healthy or unhealthy. It is safe for concurrent use. The zero value represents an unhealthy state.
Example ¶
var b Binary healthy, _ := b.Healthy(context.Background()) fmt.Println(healthy) b.MarkHealthy() healthy, _ = b.Healthy(context.Background()) fmt.Println(healthy) b.MarkUnhealthy() healthy, _ = b.Healthy(context.Background()) fmt.Println(healthy)
Output: false true false
func (*Binary) MarkHealthy ¶
func (b *Binary) MarkHealthy()
MarkHealthy changes that state to healthy.
func (*Binary) MarkUnhealthy ¶
func (b *Binary) MarkUnhealthy()
MarkUnhealthy changes the state to unhealthy.
type OrMonitor ¶
type OrMonitor []Monitor
OrMonitor is a collection of [Monitor]s which follows the logical OR (||) semantics for determining its own healthy/unhealthy state.
It will check all [Monitor]s and if any errors are encountered they will be collected and returned as a single joined error via errors.Join.
func Or ¶
Or is a simple helper for initializing a OrMonitor in a more functional style.
Example ¶
var a Binary var b Binary or := Or(&a, &b) healthy, _ := or.Healthy(context.Background()) fmt.Println(healthy) a.MarkHealthy() healthy, _ = or.Healthy(context.Background()) fmt.Println(healthy) b.MarkHealthy() healthy, _ = or.Healthy(context.Background()) fmt.Println(healthy)
Output: false true true