Documentation ¶
Overview ¶
Package handlers defines kite handlers for performing system checks.
Index ¶
- Constants
- Variables
- func Checkers(request *kite.Request) (interface{}, error)
- func LocalCheck(request *kite.Request) (interface{}, error)
- func LogRequest(request *kite.Request) (interface{}, error)
- func LogResponse(request *kite.Request) (interface{}, error)
- func NewKite(hostname string) *kite.Kite
- func RemoteCheck(request *kite.Request) (interface{}, error)
- type CheckRequest
- type CheckResult
- type Error
- type RemoteCheckResult
Constants ¶
const InvalidRemoteResponse = Error("error check gave invalid response")
InvalidRemoteResponse is used when a result from remote check can't be unmarshalled to a boolean value.
const NoSuchCheckType = Error("no such check type")
NoSuchCheckType is used when the Type value of a check request is not among supported.
const NoSuchChecker = Error("no such checker")
NoSuchChecker is used when the requested implementation of checks.Checker is not available. The user is expected to call the Checkers() endpoint.
Variables ¶
var Instance *kite.Kite
Instance is a default Kite instance setup with current hostname.
Functions ¶
func LocalCheck ¶
LocalCheck performs given checks with a selected checker.
It expects two arguments:
- Name of the check, which can be gathered from the Chercker handler.
- JSON object with list of objects, unmarshable to map[string]CheckRequest.
func LogRequest ¶
LogRequest is generic pre-handler for logging each request.
func LogResponse ¶
LogResponse is generic post-handler for logging each response.
func RemoteCheck ¶
RemoteCheck takes a slice of machine addresses, checker and a check requests to be fan-outed to those machines.
Types ¶
type CheckRequest ¶
type CheckRequest struct { // Name holds the process name expected to be running when `Type` is // `"process_is_running"`. Name string `json:"name",omitempty` // Path holds absolute path to file expected to be existing or containing a // substring. Used only when `Type` is `"file_exists`" or // `"file_contains"`. Path string `json:"path",omitempty` // Type holds the type of performed check which essentially defines which // Checker method to be executed. Possible values are: `"file_exists`", // `"file_contains"` and `"process_is_running"`. Type string `json:"type"` // Substr is substring expected to be found in given file. Used only when // `Type` is `"file_contains"`. Substr string `json:"substring",omitempty` }
CheckRequest is used to describe every single check to be performed.
type CheckResult ¶
CheckResult holds the result of given check.
func (*CheckResult) UnmarshalJSON ¶
func (cr *CheckResult) UnmarshalJSON(data []byte) error
UnmarshalJSON is needed in order to unmarshal the error value from string.
type Error ¶
type Error string
Error is a generic error type used inside this package. It's essentially a string allowing its instances to be constants.
Idea of Dave Cheney: http://dave.cheney.net/2016/04/07/constant-errors
type RemoteCheckResult ¶
type RemoteCheckResult struct { Address string Results map[string]CheckResult Error error }
RemoteCheckResult defines a check result returned from another kite.