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

Method nodeForTopic

server/cluster.go:783–796  ·  view source on GitHub ↗

Given topic name, find appropriate cluster node to route message to.

(topic string)

Source from the content-addressed store, hash-verified

781
782// Given topic name, find appropriate cluster node to route message to.
783func (c *Cluster) nodeForTopic(topic string) *ClusterNode {
784 key := c.ring.Get(topic)
785 if key == c.thisNodeName {
786 logs.Err.Println("cluster: request to route to self")
787 // Do not route to self
788 return nil
789 }
790
791 node := c.nodes[key]
792 if node == nil {
793 logs.Warn.Println("cluster: no node for topic", topic, key)
794 }
795 return node
796}
797
798// isRemoteTopic checks if the given topic is handled by this node or a remote node.
799func (c *Cluster) isRemoteTopic(topic string) bool {

Callers 4

routeUserReqMethod · 0.95
routeToTopicMasterMethod · 0.95
topicProxyGoneMethod · 0.95

Calls 2

PrintlnMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected