mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 03:00:42 -07:00
Merge pull request #1835 from nats-io/last_active
Change over last to active and a duration
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user