Documentation
¶
Overview ¶
Package readysrv is used to provide readiness checks for a service.
Example ¶
package main
import (
"context"
"net/http"
"github.com/LUSHDigital/core/workers/readysrv"
)
var ctx context.Context
func main() {
srv := readysrv.New(nil, readysrv.Checks{
"google": readysrv.CheckerFunc(func() ([]string, bool) {
if _, err := http.Get("https://google.com"); err != nil {
return []string{err.Error()}, false
}
return []string{"google can be accessed"}, true
}),
})
srv.Run(ctx)
}
Index ¶
Examples ¶
Constants ¶
View Source
const ( // DefaultAddr is the port that we listen to the prometheus path on by default. DefaultAddr = "0.0.0.0:3674" // DefaultPath is the path where we expose prometheus by default. DefaultPath = "/ready" )
Variables ¶
This section is empty.
Functions ¶
func CheckHandler ¶
func CheckHandler(checks Checks) http.HandlerFunc
CheckHandler provides a function for providing health checks over http.
Types ¶
type CheckerFunc ¶
CheckerFunc defines a single function for checking health of remote services.
func (CheckerFunc) Check ¶
func (f CheckerFunc) Check() ([]string, bool)
Check will perform the check of the checker function.
type Server ¶
type Server struct {
Path string
Checks Checks
Server *http.Server
// contains filtered or unexported fields
}
Server defines a readiness server.
func (*Server) Addr ¶ added in v0.21.0
Addr will block until you have received an address for your server.
Click to show internal directories.
Click to hide internal directories.