Documentation ¶
Overview ¶
Package readysrv is used to provide readiness checks for a service.
Example ¶
package main import ( "context" "io/ioutil" "net/http" "github.com/LUSHDigital/core/workers/readysrv" ) var ctx context.Context func main() { srv := readysrv.New(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, ioutil.Discard) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const ( // DefaultInterface is the port that we listen to the prometheus path on by default. DefaultInterface = "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.
Click to show internal directories.
Click to hide internal directories.