Documentation ¶
Overview ¶
Package httphealth provides a simple component that offers an http interface for health checking and monitoring using Prometheus.
This package is a work in progress and makes no API stability promises.
Example ¶
package main import ( "errors" "log" "math/rand" "net" "github.com/luisguillenc/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 } func main() { lis, err := net.Listen("tcp", "127.0.0.1:8081") if err != nil { log.Fatalf("listening: %v", err) } health := httphealth.New(&service{}) health.Serve(lis) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
Option encapsules options for server
func SetIPFilter ¶
SetIPFilter sets an ip filter for the health server
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 wrapped that provides a health service
Click to show internal directories.
Click to hide internal directories.