Documentation
¶
Overview ¶
Package httphealth provides a simple component that offers an http interface for health checking, monitoring (using Prometheus) and profiling.
This package is a work in progress and makes no API stability promises.
Example ¶
Creates a health server that checks a service and exposes metrics
package main
import (
"errors"
"log"
"math/rand"
"net"
"github.com/luids-io/core/httphealth"
)
// service is a supervised object
type service struct{}
// Ping implements httphealth.Pingable interface
func (s service) Ping() error {
if rand.Intn(10) > 8 {
return errors.New("error in supervised")
}
return nil
}
// Creates a health server that checks a service and exposes metrics
func main() {
lis, err := net.Listen("tcp", "127.0.0.1:8081")
if err != nil {
log.Fatalf("listening: %v", err)
}
health := httphealth.New(&service{}, httphealth.Metrics(true))
health.Serve(lis)
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pingable ¶
type Pingable interface {
Ping() error
}
Pingable must be implemented by the service to be monitored.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an http server that provides health services. It must be constructed using New.
Click to show internal directories.
Click to hide internal directories.