Documentation ¶
Index ¶
Constants ¶
const ( // StatusOK is returned when all the registered checks pass. StatusOK = "OK" StatusUnavailable = "Unavailable" )
Variables ¶
var ( // DefaultRuntimeTTL is the default TTL of the collected runtime stats. DefaultRuntimeTTL = 15 * time.Second // DefaultChecker is the default golbal checker referenced by the shortcut // functions in this package. Change this variable with caution. DefaultChecker = NewChecker(&Config{RuntimeTTL: DefaultRuntimeTTL}) )
Functions ¶
func Delete ¶
func Delete(name string)
Delete is a shortcut for DefaultChecker.Delete. See there for more information.
func Deregister ¶
func Deregister(name string)
Deregister is a shortcut for DefaultChecker.Deregister. See there for more information.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker is a health status checker responsible for evaluating the registered checks as well as of collecting useful runtime information about the Go Process. It provides an HTTP handler that returns the current health status.
func (*Checker) Deregister ¶
Deregister deregisters a check.
func (*Checker) Handler ¶
Handler returns an HTTP handler to be used as a health check endpoint. If the application is healthy and all the registered check pass, it returns a `200 OK` HTTP status code, otherwise, it fails with a `503 Service Unavailable` code. All responses contain a JSON encoded payload with information about the runtime system, current checks statuses and some configurable metadata.
type Runtime ¶
type Runtime struct { CollectedAt time.Time `json:"-"` Arch string `json:"arch"` OS string `json:"os"` Version string `json:"version"` GoroutinesCount int `json:"goroutines_count"` HeapObjectsCount int `json:"heap_objects_count"` AllocBytes int `json:"alloc_bytes"` TotalAllocBytes int `json:"total_alloc_bytes"` }
Runtime contains statistics about the Go's process.
type Status ¶
type Status struct { Status string `json:"status"` Time time.Time `json:"time"` Since time.Time `json:"since"` Runtime Runtime `json:"runtime"` Failures map[string]string `json:"failures,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
Status represents the service health status.