Merge pull request #1835 from nats-io/last_active

Change over last to active and a duration
This commit is contained in:
Derek Collison
2021-01-22 13:36:48 -07:00
committed by GitHub
2 changed files with 7 additions and 4 deletions

View File

@@ -2918,10 +2918,13 @@ func (s *Server) clusterInfo(n RaftNode) *ClusterInfo {
Leader: s.serverNameForNode(n.GroupLeader()),
}
now := time.Now()
id, peers := n.ID(), n.Peers()
for _, rp := range peers {
if rp.ID != id {
ci.Replicas = append(ci.Replicas, &PeerInfo{Name: s.serverNameForNode(rp.ID), Current: rp.Current, Last: rp.Last})
pi := &PeerInfo{Name: s.serverNameForNode(rp.ID), Current: rp.Current, Active: now.Sub(rp.Last)}
ci.Replicas = append(ci.Replicas, pi)
}
}
return ci

View File

@@ -94,9 +94,9 @@ type ClusterInfo struct {
// PeerInfo shows information about all the peers in the cluster that
// are supporting the stream or consumer.
type PeerInfo struct {
Name string `json:"name"`
Current bool `json:"current"`
Last time.Time `json:"last"`
Name string `json:"name"`
Current bool `json:"current"`
Active time.Duration `json:"active"`
}
// Stream is a jetstream stream of messages. When we receive a message internally destined