Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HealthHandler ¶ added in v0.1.19
HealthHandler returns the health endpoint for transactional processing. This Handler only checks the required health checks and returns ERR and 503 or OK and 200.
func ReadableHealthHandler ¶ added in v0.1.19
ReadableHealthHandler returns the health endpoint with all details about service health. This handler checks all health checks. The response body contains two tables (for required and optional health checks) with the detailed results of the health checks.
func RegisterHealthCheck ¶
func RegisterHealthCheck(hc HealthCheck, name string)
RegisterHealthCheck registers a required HealthCheck. The name must be unique. If the health check satisfies the Initialisable interface, it is initialised before it is added. It is not possible to add a health check with the same name twice, even if one is required and one is optional
func RegisterOptionalHealthCheck ¶ added in v0.1.19
func RegisterOptionalHealthCheck(hc HealthCheck, name string)
RegisterOptionalHealthCheck registers a HealthCheck like RegisterHealthCheck(hc HealthCheck, name string) but the health check is only checked for /health/check and not for /health/
Types ¶
type ConnectionState ¶
type ConnectionState struct {
// contains filtered or unexported fields
}
ConnectionState caches the result of health checks. It is concurrency-safe.
func (*ConnectionState) GetState ¶
func (cs *ConnectionState) GetState() HealthCheckResult
GetState returns the current state. That is whether the check is healthy or the error occurred.
func (*ConnectionState) LastChecked ¶
func (cs *ConnectionState) LastChecked() time.Time
LastChecked returns the time that the state was last updated or confirmed.
func (*ConnectionState) SetErrorState ¶
func (cs *ConnectionState) SetErrorState(err error)
SetErrorState sets the state to not healthy.
func (*ConnectionState) SetHealthy ¶
func (cs *ConnectionState) SetHealthy()
SetHealthy sets the state to healthy.
type HealthCheck ¶
type HealthCheck interface {
HealthCheck(ctx context.Context) HealthCheckResult
}
HealthCheck is a health check that is registered once and that is performed periodically and/or spontaneously.
type HealthCheckResult ¶ added in v0.1.19
type HealthCheckResult struct { State HealthState Msg string }
HealthCheckResult describes the result of a health check, contains the state of a service and a message that describes the state. If the state is Ok the description can be empty. The description should contain the error message if any error or warning occurred during the health check.
type HealthState ¶ added in v0.1.19
type HealthState string
HealthState describes if a any error or warning occurred during the health check of a service
const ( // Err State of a service, if an error occurred during the health check of the service Err HealthState = "ERR" // Warn State of a service, if a warning occurred during the health check of the service Warn HealthState = "WARN" // Ok State of a service, if no warning or error occurred during the health check of the service Ok HealthState = "OK" )
type Initialisable ¶
type Initialisable interface {
Init() error
}
Initialisable is used to mark that a health check needs to be initialized