Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
Checker defines the methods necessary to determine if a certain aspect of a service should be considered healthy. If the Check function returns nil, the instance is healthy. Otherwise, it's unhealthy. The LogInfo method should return a string that contains debug information or other useful identifying information for the log output when Check returns an error.
type Checks ¶
type Checks struct { Checks []Checker // This property will be deprecated once Go 1.7 is released Context context.Context Logger func(format string, msg ...interface{}) }
Checks defines a group of Checkers, a log function to write their errors with, and a context to associate with the Checkers. Checks is an http.Handler.
func NewChecks ¶
func NewChecks(ctx context.Context, logger func(format string, msg ...interface{}), checks ...Checker) Checks
NewChecks returns a Checks instance using the passed context, logging function, and Checkers.
func (Checks) ServeHTTP ¶
func (c Checks) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP fulfills the http.Handler interface. Calling ServeHTTP will call the Check method on all the Checkers associated with the Checks. If any of the Checkers returns an error, a response with status 500 is written and the error is logged. Otherwise, a response with status 200 is written, and the text "OK" is written to the response.
type SQL ¶
SQL is a type that fills the Checker interface for an *sql.DB. ID is used as the identifying information returned by LogInfo, which is useful if more than one *sql.DB is needed for a service's health check.