|
|
|
@ -4,6 +4,16 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// HealthAny is special, and is used as a wild card,
|
|
|
|
|
// not as a specific state.
|
|
|
|
|
HealthAny = "any"
|
|
|
|
|
HealthUnknown = "unknown"
|
|
|
|
|
HealthPassing = "passing"
|
|
|
|
|
HealthWarning = "warning"
|
|
|
|
|
HealthCritical = "critical"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// HealthCheck is used to represent a single check
|
|
|
|
|
type HealthCheck struct {
|
|
|
|
|
Node string
|
|
|
|
@ -85,7 +95,7 @@ func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions)
|
|
|
|
|
r.params.Set("tag", tag)
|
|
|
|
|
}
|
|
|
|
|
if passingOnly {
|
|
|
|
|
r.params.Set("passing", "1")
|
|
|
|
|
r.params.Set(HealthPassing, "1")
|
|
|
|
|
}
|
|
|
|
|
rtt, resp, err := requireOK(h.c.doRequest(r))
|
|
|
|
|
if err != nil {
|
|
|
|
@ -108,11 +118,11 @@ func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions)
|
|
|
|
|
// The wildcard "any" state can also be used for all checks.
|
|
|
|
|
func (h *Health) State(state string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
|
|
|
|
|
switch state {
|
|
|
|
|
case "any":
|
|
|
|
|
case "warning":
|
|
|
|
|
case "critical":
|
|
|
|
|
case "passing":
|
|
|
|
|
case "unknown":
|
|
|
|
|
case HealthAny:
|
|
|
|
|
case HealthWarning:
|
|
|
|
|
case HealthCritical:
|
|
|
|
|
case HealthPassing:
|
|
|
|
|
case HealthUnknown:
|
|
|
|
|
default:
|
|
|
|
|
return nil, nil, fmt.Errorf("Unsupported state: %v", state)
|
|
|
|
|
}
|
|
|
|
|