Documentation
¶
Index ¶
- Constants
- func NewGetAndPostHandler(log log.Logger, reporter Reporter) (http.Handler, error)
- func NewGetHandler(reporter func(tags ...string) (map[string]apihealth.Result, bool)) http.Handler
- type Checker
- type CheckerFunc
- type Health
- type Registerer
- type Reporter
- type Service
- func (s *Service) Health(_ *http.Request, args *apihealth.APIArgs, reply *apihealth.APIReply) error
- func (s *Service) Liveness(_ *http.Request, args *apihealth.APIArgs, reply *apihealth.APIReply) error
- func (s *Service) Readiness(_ *http.Request, args *apihealth.APIArgs, reply *apihealth.APIReply) error
Constants ¶
View Source
const ( // CheckLabel is the label used to differentiate between health checks. CheckLabel = "check" // TagLabel is the label used to differentiate between health check tags. TagLabel = "tag" // AllTag is automatically added to every registered check. AllTag = "all" // ApplicationTag checks will act as if they specified every tag that has // been registered. // Registering a health check with this tag will ensure that it is always // included in all health query results. ApplicationTag = "application" )
Variables ¶
This section is empty.
Functions ¶
func NewGetAndPostHandler ¶
NewGetAndPostHandler returns a health handler that supports GET and jsonrpc POST requests.
Types ¶
type Checker ¶
type Checker interface {
// HealthCheck returns health check results and, if not healthy, a non-nil
// error
//
// It is expected that the results are json marshallable.
HealthCheck(context.Context) (interface{}, error)
}
Checker can have its health checked
type CheckerFunc ¶
func (CheckerFunc) HealthCheck ¶
func (f CheckerFunc) HealthCheck(ctx context.Context) (interface{}, error)
type Health ¶
type Health interface {
Registerer
Reporter
// Start running periodic health checks at the specified frequency.
// Repeated calls to Start will be no-ops.
Start(ctx context.Context, freq time.Duration)
// Stop running periodic health checks. Stop should only be called after
// Start. Once Stop returns, no more health checks will be executed.
Stop()
}
Health defines the full health service interface for registering, reporting and refreshing health checks.
type Registerer ¶
type Registerer interface {
RegisterReadinessCheck(name string, checker Checker, tags ...string) error
RegisterHealthCheck(name string, checker Checker, tags ...string) error
RegisterLivenessCheck(name string, checker Checker, tags ...string) error
}
Registerer defines how to register new components to check the health of.
type Reporter ¶
type Reporter interface {
Readiness(tags ...string) (map[string]apihealth.Result, bool)
Health(tags ...string) (map[string]apihealth.Result, bool)
Liveness(tags ...string) (map[string]apihealth.Result, bool)
}
Reporter returns the current health status.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements the health API with gorilla/rpc-compatible signatures.
Click to show internal directories.
Click to hide internal directories.