add accessor method for Node.status

This commit is contained in:
Travis Turner 2018-01-24 17:03:58 -06:00
parent 88fa51e6bf
commit 878b188155
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9

View file

@ -42,10 +42,17 @@ type Node struct {
Scheme string `json:"scheme"`
Host string `json:"host"`
mu sync.Mutex
mu sync.RWMutex
status *internal.NodeStatus `json:"status"`
}
// Status gets the NodeStatus.
func (n *Node) Status() *internal.NodeStatus {
n.mu.RLock()
defer n.mu.RUnlock()
return n.status
}
// SetStatus sets the NodeStatus.
func (n *Node) SetStatus(s *internal.NodeStatus) {
n.mu.Lock()
@ -203,7 +210,7 @@ func (c *Cluster) Status() *internal.ClusterStatus {
func encodeClusterStatus(a []*Node) []*internal.NodeStatus {
other := make([]*internal.NodeStatus, len(a))
for i := range a {
other[i] = a[i].status
other[i] = a[i].Status()
}
return other
}