Documentation
¶
Index ¶
- type AggregationPolicy
- type DefaultAggregationPolicy
- type Health
- func (h *Health) Down() *Health
- func (h *Health) Unknown() *Health
- func (h *Health) Up() *Health
- func (h *Health) WithDetail(key string, val interface{}) *Health
- func (h *Health) WithDetails(details map[string]interface{}) *Health
- func (h *Health) WithError(err error) *Health
- func (h *Health) WithStatus(status Status) *Health
- type Indicator
- type Registry
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationPolicy ¶
type AggregationPolicy interface {
// Apply processes the given healths to build a single health
Apply(healths map[string]*Health) *Health
}
AggregationPolicy is an interface to provide aggregated health information
type DefaultAggregationPolicy ¶
type DefaultAggregationPolicy struct {
}
DefaultAggregationPolicy aggregates the healths by constructing a new Health based on the given where the overall health status is negative if one of the healths is negative and positive if all are positive
type Health ¶
type Health struct {
Status Status `json:"status"`
Details map[string]interface{} `json:"details,omitempty"`
}
Health contains information about the health of a component.
func (*Health) WithDetail ¶
WithDetail adds a detail to the health
func (*Health) WithDetails ¶
WithDetails adds the given details to the health
func (*Health) WithStatus ¶
WithStatus sets the status of the health
type Indicator ¶
type Indicator interface {
// Name returns the name of the component
Name() string
// Health returns the health of the component
Health() *Health
}
Indicator is an interface to provide the health of a component
type Registry ¶
type Registry interface {
// AddHealthIndicators registers a new health indicator
AddHealthIndicator(indicator Indicator)
// HealthIndicators returns the currently registered health indicators
HealthIndicators() []Indicator
// RegisterHealthAggregationPolicy sets the health aggregationPolicy
RegisterHealthAggregationPolicy(aggregator AggregationPolicy)
// HealthAggregationPolicy returns the registered health aggregationPolicy
HealthAggregationPolicy() AggregationPolicy
}
Registry is an interface to store and fetch health indicators
func NewDefaultRegistry ¶
func NewDefaultRegistry() Registry
NewDefaultRegistry returns a default health registry with a single ping indicator and a default aggregation policy
type Status ¶
type Status string
Status represents the overall health status of a component
const ( // StatusUp indicates that the checked component is up and running StatusUp Status = "UP" // StatusDown indicates the the checked component has an issue and is unavailable StatusDown Status = "DOWN" // StatusUnknown indicates that the health of the checked component cannot be determined StatusUnknown Status = "UNKNOWN" )