Skip to content

Commit

Permalink
API updates for the fix-cluster-health feature
Browse files Browse the repository at this point in the history
  • Loading branch information
J.C.Reid committed Nov 23, 2018
1 parent 29374b2 commit 5b37613
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ var (
HealthAPIPrefix = "health"
)

func (c *Client) ClusterHealth(ctx context.Context) ([]*types.ClusterHealthNode, error) {
status := []*types.ClusterHealthNode{}
url := fmt.Sprintf("/cluster/%s", HealthAPIPrefix)

resp, err := c.do("GET", url, doOptions{context: ctx})
if err != nil {
return nil, err
}
defer resp.Body.Close()

if err := json.NewDecoder(resp.Body).Decode(&status); err != nil {
return nil, err
}
return status, nil
}

// CPHealth returns the health of the control plane server at a given url.
func (c *Client) CPHealth(ctx context.Context, hostname string) (*types.CPHealthStatus, error) {

Expand Down
14 changes: 14 additions & 0 deletions types/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ type NamedSubModuleStatus struct {
SubModuleStatus
}

type ClusterHealthNode struct {
NodeID string `json:"nodeID"`
NodeName string `json:"nodeName"`
Submodules struct {
DirectFSInitiator SubModuleStatus `json:"directfs_initiator"`
Director SubModuleStatus `json:"director"`
KV SubModuleStatus `json:"kv"`
KVWrite SubModuleStatus `json:"kv_write"`
NATS SubModuleStatus `json:"nats"`
Presentation SubModuleStatus `json:"presentation"`
RDB SubModuleStatus `json:"rdb"`
} `json:"submodules"`
}

type CPHealthStatus struct {
KV SubModuleStatus
KVWrite SubModuleStatus
Expand Down

0 comments on commit 5b37613

Please sign in to comment.