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

Method Route

server/cluster.go:635–663  ·  view source on GitHub ↗

Route endpoint receives intra-cluster messages destined for the nodes hosting the topic. Called by Hub.route channel consumer for messages send without attaching to topic first.

(msg *ClusterRoute, rejected *bool)

Source from the content-addressed store, hash-verified

633// Route endpoint receives intra-cluster messages destined for the nodes hosting the topic.
634// Called by Hub.route channel consumer for messages send without attaching to topic first.
635func (c *Cluster) Route(msg *ClusterRoute, rejected *bool) error {
636 logError := func(err string) {
637 sid := ""
638 if msg.Sess != nil {
639 sid = msg.Sess.Sid
640 }
641 logs.Warn.Println(err, sid)
642 *rejected = true
643 }
644
645 *rejected = false
646 if msg.Signature != c.ring.Signature() {
647 logError("cluster Route: session signature mismatch")
648 return nil
649 }
650
651 if msg.SrvMsg == nil {
652 // TODO: maybe panic here.
653 logError("cluster Route: nil server message")
654 return nil
655 }
656
657 select {
658 case globals.hub.routeSrv <- msg.SrvMsg:
659 default:
660 logError("cluster Route: server busy")
661 }
662 return nil
663}
664
665// User cache & push notifications management. These are calls received by the Master from Proxy.
666// The Proxy expects no payload to be returned by the master.

Callers

nothing calls this directly

Calls 2

PrintlnMethod · 0.80
SignatureMethod · 0.80

Tested by

no test coverage detected