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

Method makeClusterReq

server/cluster.go:837–873  ·  view source on GitHub ↗
(reqType ProxyReqType, msg *ClientComMessage, topic string, sess *Session)

Source from the content-addressed store, hash-verified

835}
836
837func (c *Cluster) makeClusterReq(reqType ProxyReqType, msg *ClientComMessage, topic string, sess *Session) *ClusterReq {
838 req := &ClusterReq{
839 Node: c.thisNodeName,
840 Signature: c.ring.Signature(),
841 Fingerprint: c.fingerprint,
842 ReqType: reqType,
843 RcptTo: topic,
844 }
845
846 var uid types.Uid
847
848 if msg != nil {
849 req.CliMsg = msg
850 uid = types.ParseUserId(req.CliMsg.AsUser)
851 }
852
853 if sess != nil {
854 if uid.IsZero() {
855 uid = sess.uid
856 }
857
858 req.Sess = &ClusterSess{
859 Uid: uid,
860 AuthLvl: sess.authLvl,
861 RemoteAddr: sess.remoteAddr,
862 UserAgent: sess.userAgent,
863 Ver: sess.ver,
864 Lang: sess.lang,
865 CountryCode: sess.countryCode,
866 DeviceID: sess.deviceID,
867 Platform: sess.platf,
868 Sid: sess.sid,
869 Background: sess.background,
870 }
871 }
872 return req
873}
874
875// Forward client request message from the Topic Proxy to the Topic Master (cluster node which owns the topic).
876func (c *Cluster) routeToTopicMaster(reqType ProxyReqType, msg *ClientComMessage, topic string, sess *Session) error {

Callers 2

routeToTopicMasterMethod · 0.95
topicProxyGoneMethod · 0.95

Calls 3

IsZeroMethod · 0.95
ParseUserIdFunction · 0.92
SignatureMethod · 0.80

Tested by

no test coverage detected