bricks: github.com/pace/bricks/maintenance/health/servicehealthcheck Index | Files

package servicehealthcheck

import "github.com/pace/bricks/maintenance/health/servicehealthcheck"

Index

Package Files

connection_state.go health_handler.go healthchecker.go readable_health_handler.go

func HealthHandler Uses

func HealthHandler() http.Handler

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 Uses

func ReadableHealthHandler() http.Handler

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 Uses

func RegisterHealthCheck(name string, hc HealthCheck)

RegisterHealthCheck registers a required HealthCheck. The name must be unique. If the health check satisfies the Initializable interface, it is initialized 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 RegisterHealthCheckFunc Uses

func RegisterHealthCheckFunc(name string, f HealthCheckFunc)

RegisterHealthCheckFunc registers a required HealthCheck. The name must be unique. 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 Uses

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/

type ConnectionState Uses

type ConnectionState struct {
    // contains filtered or unexported fields
}

ConnectionState caches the result of health checks. It is concurrency-safe.

func (*ConnectionState) GetState Uses

func (cs *ConnectionState) GetState() HealthCheckResult

GetState returns the current state. That is whether the check is healthy or the error occurred.

func (*ConnectionState) LastChecked Uses

func (cs *ConnectionState) LastChecked() time.Time

LastChecked returns the time that the state was last updated or confirmed.

func (*ConnectionState) SetErrorState Uses

func (cs *ConnectionState) SetErrorState(err error)

SetErrorState sets the state to not healthy.

func (*ConnectionState) SetHealthy Uses

func (cs *ConnectionState) SetHealthy()

SetHealthy sets the state to healthy.

type HealthCheck Uses

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 HealthCheckFunc Uses

type HealthCheckFunc func(ctx context.Context) HealthCheckResult

func (HealthCheckFunc) HealthCheck Uses

func (hcf HealthCheckFunc) HealthCheck(ctx context.Context) HealthCheckResult

type HealthCheckResult Uses

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 Uses

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 Initializable Uses

type Initializable interface {
    Init(ctx context.Context) error
}

Initializable is used to mark that a health check needs to be initialized

Package servicehealthcheck imports 10 packages (graph) and is imported by 5 packages. Updated 2020-11-24. Refresh now. Tools for package owners.