summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/armon/consul-api/health.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/armon/consul-api/health.go
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/armon/consul-api/health.go')
-rw-r--r--vendor/github.com/armon/consul-api/health.go136
1 files changed, 0 insertions, 136 deletions
diff --git a/vendor/github.com/armon/consul-api/health.go b/vendor/github.com/armon/consul-api/health.go
deleted file mode 100644
index 12225790..00000000
--- a/vendor/github.com/armon/consul-api/health.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package consulapi
-
-import (
- "fmt"
-)
-
-// HealthCheck is used to represent a single check
-type HealthCheck struct {
- Node string
- CheckID string
- Name string
- Status string
- Notes string
- Output string
- ServiceID string
- ServiceName string
-}
-
-// ServiceEntry is used for the health service endpoint
-type ServiceEntry struct {
- Node *Node
- Service *AgentService
- Checks []*HealthCheck
-}
-
-// Health can be used to query the Health endpoints
-type Health struct {
- c *Client
-}
-
-// Health returns a handle to the health endpoints
-func (c *Client) Health() *Health {
- return &Health{c}
-}
-
-// Node is used to query for checks belonging to a given node
-func (h *Health) Node(node string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/node/"+node)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Checks is used to return the checks associated with a service
-func (h *Health) Checks(service string, q *QueryOptions) ([]*HealthCheck, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/checks/"+service)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// Service is used to query health information along with service info
-// for a given service. It can optionally do server-side filtering on a tag
-// or nodes with passing health checks only.
-func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions) ([]*ServiceEntry, *QueryMeta, error) {
- r := h.c.newRequest("GET", "/v1/health/service/"+service)
- r.setQueryOptions(q)
- if tag != "" {
- r.params.Set("tag", tag)
- }
- if passingOnly {
- r.params.Set("passing", "1")
- }
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*ServiceEntry
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}
-
-// State is used to retrieve all the checks in a given state.
-// 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":
- default:
- return nil, nil, fmt.Errorf("Unsupported state: %v", state)
- }
- r := h.c.newRequest("GET", "/v1/health/state/"+state)
- r.setQueryOptions(q)
- rtt, resp, err := requireOK(h.c.doRequest(r))
- if err != nil {
- return nil, nil, err
- }
- defer resp.Body.Close()
-
- qm := &QueryMeta{}
- parseQueryMeta(resp, qm)
- qm.RequestTime = rtt
-
- var out []*HealthCheck
- if err := decodeBody(resp, &out); err != nil {
- return nil, nil, err
- }
- return out, qm, nil
-}