@@ -34,6 +34,7 @@ import (
3434 rh "github.com/unit-io/unitdb/server/internal/pkg/hash"
3535 "github.com/unit-io/unitdb/server/internal/pkg/log"
3636 "github.com/unit-io/unitdb/server/internal/pkg/uid"
37+ "github.com/unit-io/unitdb/server/utp"
3738)
3839
3940const (
@@ -103,9 +104,9 @@ type ClusterReq struct {
103104 // Cluster is desynchronized.
104105 Signature string
105106
106- MsgSub * lp .Subscribe
107- MsgPub * lp .Publish
108- MsgUnsub * lp .Unsubscribe
107+ MsgSub * utp .Subscribe
108+ MsgPub * utp .Publish
109+ MsgUnsub * utp .Unsubscribe
109110 Topic * security.Topic
110111 Type uint8
111112 Message * message.Message
@@ -119,9 +120,9 @@ type ClusterReq struct {
119120// ClusterResp is a Master to Proxy response message.
120121type ClusterResp struct {
121122 Type uint8
122- MsgSub * lp .Subscribe
123- MsgPub * lp .Publish
124- MsgUnsub * lp .Unsubscribe
123+ MsgSub * utp .Subscribe
124+ MsgPub * utp .Publish
125+ MsgUnsub * utp .Unsubscribe
125126 Msg []byte
126127 Topic * security.Topic
127128 Message * message.Message
@@ -310,7 +311,6 @@ func (c *Cluster) Master(msg *ClusterReq, rejected *bool) error {
310311 go conn .rpcWriteLoop ()
311312 }
312313 // Update session params which may have changed since the last call.
313- conn .proto = msg .Conn .Proto
314314 conn .connID = msg .Conn .ConnID
315315 conn .clientID = msg .Conn .ClientID
316316
@@ -373,7 +373,7 @@ func (c *Cluster) isRemoteContract(contract string) bool {
373373}
374374
375375// Forward client message to the Master (cluster node which owns the topic)
376- func (c * Cluster ) routeToContract (msg lp.LineProtocol , topic * security.Topic , msgType uint8 , m * message.Message , conn * _Conn ) error {
376+ func (c * Cluster ) routeToContract (msg lp.MessagePack , topic * security.Topic , msgType uint8 , m * message.Message , conn * _Conn ) error {
377377 // Find the cluster node which owns the topic, then forward to it.
378378 n := c .nodeForContract (fmt .Sprint (conn .clientID .Contract ()))
379379 if n == nil {
@@ -387,18 +387,18 @@ func (c *Cluster) routeToContract(msg lp.LineProtocol, topic *security.Topic, ms
387387 conn .nodes [n .name ] = true
388388
389389 // var msgSub,msgPub,msgUnsub lp.Packet
390- var msgSub * lp .Subscribe
391- var msgPub * lp .Publish
392- var msgUnsub * lp .Unsubscribe
390+ var msgSub * utp .Subscribe
391+ var msgPub * utp .Publish
392+ var msgUnsub * utp .Unsubscribe
393393 switch msgType {
394394 case message .SUBSCRIBE :
395- msgSub = msg .(* lp .Subscribe )
395+ msgSub = msg .(* utp .Subscribe )
396396 msgSub .IsForwarded = true
397397 case message .UNSUBSCRIBE :
398- msgUnsub = msg .(* lp .Unsubscribe )
398+ msgUnsub = msg .(* utp .Unsubscribe )
399399 msgUnsub .IsForwarded = true
400400 case message .PUBLISH :
401- msgPub = msg .(* lp .Publish )
401+ msgPub = msg .(* utp .Publish )
402402 msgPub .IsForwarded = true
403403 }
404404 return n .forward (
@@ -413,7 +413,6 @@ func (c *Cluster) routeToContract(msg lp.LineProtocol, topic *security.Topic, ms
413413 Message : m ,
414414 Conn : & ClusterSess {
415415 //RemoteAddr: conn.(),
416- Proto : conn .proto ,
417416 ConnID : conn .connID ,
418417 SessID : conn .sessID ,
419418 ClientID : conn .clientID }})
@@ -471,9 +470,9 @@ func ClusterInit(configString json.RawMessage, self *string) int {
471470
472471 gob .Register ([]interface {}{})
473472 gob .Register (map [string ]interface {}{})
474- gob .Register (lp .Publish {})
475- gob .Register (lp .Subscribe {})
476- gob .Register (lp .Unsubscribe {})
473+ gob .Register (utp .Publish {})
474+ gob .Register (utp .Subscribe {})
475+ gob .Register (utp .Unsubscribe {})
477476
478477 Globals .Cluster = & Cluster {
479478 thisNodeName : thisName ,
@@ -530,10 +529,7 @@ func (c *_Conn) rpcWriteLoop() {
530529 // channel closed
531530 return
532531 }
533- if c .adp == nil {
534- return
535- }
536- m , err := lp .Encode (c .adp , msg )
532+ m , err := lp .Encode (msg )
537533 if err != nil {
538534 log .Error ("conn.writeRpc" , err .Error ())
539535 return
0 commit comments