Documentation
¶
Index ¶
- func Grouped(log *slog.Logger, serviceName string, checks ...HealthCheck) *groupedHealthCheck
- type AsyncHealthCheck
- func (c *AsyncHealthCheck) Check(_ context.Context) (HealthResult, error)
- func (r *AsyncHealthCheck) ForceUpdateStatus(ctx context.Context) error
- func (c *AsyncHealthCheck) ServiceName() string
- func (r *AsyncHealthCheck) Start(ctx context.Context)
- func (r *AsyncHealthCheck) Stop(ctx context.Context)
- type DelayedErrorHealthCheck
- type HealthCheck
- type HealthResult
- type HealthStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsyncHealthCheck ¶
type AsyncHealthCheck struct {
// contains filtered or unexported fields
}
func Async ¶
func Async(log *slog.Logger, interval time.Duration, hc HealthCheck) *AsyncHealthCheck
func (*AsyncHealthCheck) Check ¶
func (c *AsyncHealthCheck) Check(_ context.Context) (HealthResult, error)
func (*AsyncHealthCheck) ForceUpdateStatus ¶
func (r *AsyncHealthCheck) ForceUpdateStatus(ctx context.Context) error
func (*AsyncHealthCheck) ServiceName ¶
func (c *AsyncHealthCheck) ServiceName() string
func (*AsyncHealthCheck) Start ¶
func (r *AsyncHealthCheck) Start(ctx context.Context)
func (*AsyncHealthCheck) Stop ¶
func (r *AsyncHealthCheck) Stop(ctx context.Context)
type DelayedErrorHealthCheck ¶
type DelayedErrorHealthCheck struct {
// contains filtered or unexported fields
}
func DelayErrors ¶
func DelayErrors(log *slog.Logger, maxIgnoredErrors int, hc HealthCheck) *DelayedErrorHealthCheck
func (*DelayedErrorHealthCheck) Check ¶
func (c *DelayedErrorHealthCheck) Check(ctx context.Context) (HealthResult, error)
func (*DelayedErrorHealthCheck) ServiceName ¶
func (c *DelayedErrorHealthCheck) ServiceName() string
type HealthCheck ¶
type HealthCheck interface { // ServiceName returns the name of the service that is health checked. ServiceName() string // Check is a function returning a service status and an error. Check(ctx context.Context) (HealthResult, error) }
HealthCheck defines an interface for health checks.
type HealthResult ¶
type HealthResult struct { // Status indicates the overall health state. Status HealthStatus // Message gives additional information on the overall health state. Message string // Services contain the individual health results of the services as evaluated by the HealthCheck interface. The overall HealthStatus is then derived automatically from the results of the health checks. // // Note that the individual HealthResults evaluated by the HealthCheck interface may again consist of a plurality services. While this is only optional it allows for creating nested health structures. These can be used for more sophisticated scenarios like evaluating platform health describing service availability in different locations or similar. // // If using nested HealthResults, the status of the parent service can be derived automatically from the status of its children by leaving the parent's health status field blank. Services map[string]HealthResult }
HealthResult holds the health state of a service.
type HealthStatus ¶
type HealthStatus string
HealthStatus indicates the health of a service.
const ( // HealthStatusHealthy is returned when the service is healthy. HealthStatusHealthy HealthStatus = "healthy" // HealthStatusUnhealthy is returned when the service is not healthy. HealthStatusUnhealthy HealthStatus = "unhealthy" // HealthStatusDegraded is returned when the service is degraded. HealthStatusDegraded HealthStatus = "degraded" // HealthStatusPartiallyUnhealthy is returned when the service is partially not healthy. HealthStatusPartiallyUnhealthy HealthStatus = "partial-outage" )
func DeriveOverallHealthStatus ¶
func DeriveOverallHealthStatus(services map[string]HealthResult) HealthStatus
Click to show internal directories.
Click to hide internal directories.