Given topic name, find appropriate cluster node to route message to.
(topic string)
| 781 | |
| 782 | // Given topic name, find appropriate cluster node to route message to. |
| 783 | func (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. |
| 799 | func (c *Cluster) isRemoteTopic(topic string) bool { |
no test coverage detected