MCPcopy
hub / github.com/tinode/chat / Ping

Method Ping

server/cluster.go:685–703  ·  view source on GitHub ↗

Ping is a gRPC endpoint which receives ping requests from peer nodes.Used to detect node restarts.

(ping *ClusterPing, unused *bool)

Source from the content-addressed store, hash-verified

683
684// Ping is a gRPC endpoint which receives ping requests from peer nodes.Used to detect node restarts.
685func (c *Cluster) Ping(ping *ClusterPing, unused *bool) error {
686 node := c.nodes[ping.Node]
687 if node == nil {
688 logs.Warn.Println("cluster Ping from unknown node", ping.Node)
689 return nil
690 }
691
692 if node.fingerprint == 0 {
693 // This is the first connection to remote node.
694 node.fingerprint = ping.Fingerprint
695 } else if node.fingerprint != ping.Fingerprint {
696 // Remote node restarted.
697 node.fingerprint = ping.Fingerprint
698 c.invalidateProxySubs(ping.Node)
699 c.gcProxySessionsForNode(ping.Node)
700 }
701
702 return nil
703}
704
705// Sends user cache update to user's Master node where the cache actually resides.
706// The request is extected to contain users who reside at remote nodes only.

Callers 3

OpenMethod · 0.80
OpenMethod · 0.80
TestUserCreateFunction · 0.80

Calls 3

invalidateProxySubsMethod · 0.95
PrintlnMethod · 0.80

Tested by 1

TestUserCreateFunction · 0.64