mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Add all node states to /status response
This commit is contained in:
parent
664c911791
commit
8fad2b92c2
3 changed files with 17 additions and 3 deletions
6
api.go
6
api.go
|
|
@ -776,6 +776,12 @@ func (api *API) Hosts(ctx context.Context) []*Node {
|
|||
return api.cluster.Nodes()
|
||||
}
|
||||
|
||||
func (api *API) HostStates(ctx context.Context) map[string]string {
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "API.HostStates")
|
||||
defer span.Finish()
|
||||
return api.cluster.AllNodeStates()
|
||||
}
|
||||
|
||||
// Node gets the ID, URI and coordinator status for this particular node.
|
||||
func (api *API) Node() *Node {
|
||||
node := api.server.node()
|
||||
|
|
|
|||
|
|
@ -700,6 +700,12 @@ func (c *cluster) Nodes() []*Node {
|
|||
return ret
|
||||
}
|
||||
|
||||
func (c *cluster) AllNodeStates() map[string]string {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
return c.Topology.nodeStates
|
||||
}
|
||||
|
||||
// removeNodeBasicSorted removes a node from the cluster, maintaining the sort
|
||||
// order. Returns true if the node was removed. unprotected.
|
||||
func (c *cluster) removeNodeBasicSorted(nodeID string) bool {
|
||||
|
|
|
|||
|
|
@ -702,6 +702,7 @@ func (h *Handler) handleGetStatus(w http.ResponseWriter, r *http.Request) {
|
|||
status := getStatusResponse{
|
||||
State: h.api.State(),
|
||||
Nodes: h.api.Hosts(r.Context()),
|
||||
NodeStates: h.api.HostStates(r.Context()),
|
||||
LocalID: h.api.Node().ID,
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
@ -758,9 +759,10 @@ type getSchemaResponse struct {
|
|||
}
|
||||
|
||||
type getStatusResponse struct {
|
||||
State string `json:"state"`
|
||||
Nodes []*pilosa.Node `json:"nodes"`
|
||||
LocalID string `json:"localID"`
|
||||
State string `json:"state"`
|
||||
Nodes []*pilosa.Node `json:"nodes"`
|
||||
NodeStates map[string]string `json:"nodeStates"`
|
||||
LocalID string `json:"localID"`
|
||||
}
|
||||
|
||||
func hash(s string) string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue