handlers

package
v0.0.0-...-841a420 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// The Handler is an http.Handler, so it can be exposed directly and handle
	// /live and /ready endpoints.
	http.Handler

	// AddLivenessCheck adds a check that indicates that this instance of the
	// application should be destroyed or restarted. A failed liveness check
	// indicates that this instance is unhealthy, not some upstream dependency.
	// Every liveness check is also included as a readiness check.
	AddLivenessCheck(name string, check healthcheck.Check)

	// AddReadinessCheck adds a check that indicates that this instance of the
	// application is currently unable to serve requests because of an upstream
	// or some transient failure. If a readiness check fails, this instance
	// should no longer receiver requests, but should not be restarted or
	// destroyed.
	AddReadinessCheck(name string, check healthcheck.Check)

	// LiveEndpoint is the HTTP handlers for just the /live endpoint, which is
	// useful if you need to attach it into your own HTTP handlers tree.
	LiveEndpoint(http.ResponseWriter, *http.Request)

	// ReadyEndpoint is the HTTP handlers for just the /ready endpoint, which is
	// useful if you need to attach it into your own HTTP handlers tree.
	ReadyEndpoint(http.ResponseWriter, *http.Request)
}

Handler is an http.Handler with additional methods that register health and readiness checks. It handles "/live" and "/ready" HTTP endpoints.

func NewHandler

func NewHandler(options Options) Handler

creates a handlers that listens on /live & /ready and returns liveness and readiness statuses for each provided livenessChecks & readynessChecks it also returns metadata in each response

func NewMetricsHandler

func NewMetricsHandler(registry prometheus.Registerer, namespace string, options Options) Handler

NewMetricsHandler returns a healthcheck Handler that also exposes metrics into the provided Prometheus registry.

type Options

type Options struct {
	Metadata map[string]string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL