@@ -29,7 +29,7 @@ import (
2929 "github.com/unit-io/unitdb/server/internal/message"
3030 "github.com/unit-io/unitdb/server/internal/message/security"
3131 lp "github.com/unit-io/unitdb/server/internal/net"
32- "github.com/unit-io/unitdb/server/internal/net/grpc "
32+ "github.com/unit-io/unitdb/server/internal/net/pubsub "
3333 "github.com/unit-io/unitdb/server/internal/pkg/log"
3434 "github.com/unit-io/unitdb/server/internal/pkg/uid"
3535 "github.com/unit-io/unitdb/server/internal/store"
@@ -44,8 +44,8 @@ type _Conn struct {
4444 adp lp.ProtoAdapter
4545 socket net.Conn
4646 // send chan []byte
47- send chan lp.Packet
48- recv chan lp.Packet
47+ send chan lp.LineProtocol
48+ recv chan lp.LineProtocol
4949 pub chan * lp.Publish
5050 stop chan interface {}
5151 insecure bool // The insecure flag provided by client will not perform key validation and permissions check on the topic.
@@ -65,21 +65,13 @@ type _Conn struct {
6565 closeC chan struct {}
6666}
6767
68- func (s * _Service ) newConn (t net.Conn , proto lp.Proto ) * _Conn {
69- var adp lp.ProtoAdapter
70- switch proto {
71- case lp .GRPC :
72- adp = & grpc.LineProto {}
73- case lp .GRPC_WEB :
74- adp = & grpc.LineProto {}
75- }
76-
68+ func (s * _Service ) newConn (t net.Conn ) * _Conn {
7769 c := & _Conn {
78- adp : adp ,
70+ adp : & pubsub. Packet {} ,
7971 socket : t ,
8072 MessageIds : message .NewMessageIds (),
81- send : make (chan lp.Packet , 1 ), // buffered
82- recv : make (chan lp.Packet ),
73+ send : make (chan lp.LineProtocol , 1 ), // buffered
74+ recv : make (chan lp.LineProtocol ),
8375 pub : make (chan * lp.Publish ),
8476 stop : make (chan interface {}, 1 ), // Buffered by 1 just to make it non-blocking
8577 connid : uid .NewLID (),
@@ -97,21 +89,14 @@ func (s *_Service) newConn(t net.Conn, proto lp.Proto) *_Conn {
9789}
9890
9991// newRpcConn a new connection in cluster
100- func (s * _Service ) newRpcConn (conn interface {}, proto lp.Proto , connid uid.LID , clientid uid.ID ) * _Conn {
101- var adp lp.ProtoAdapter
102- switch proto {
103- case lp .GRPC :
104- adp = & grpc.LineProto {}
105- case lp .GRPC_WEB :
106- adp = & grpc.LineProto {}
107- }
92+ func (s * _Service ) newRpcConn (conn interface {}, connid uid.LID , clientid uid.ID ) * _Conn {
10893 c := & _Conn {
109- adp : adp ,
94+ adp : & pubsub. Packet {} ,
11095 connid : connid ,
11196 clientid : clientid ,
11297 MessageIds : message .NewMessageIds (),
113- send : make (chan lp.Packet , 1 ), // buffered
114- recv : make (chan lp.Packet ),
98+ send : make (chan lp.LineProtocol , 1 ), // buffered
99+ recv : make (chan lp.LineProtocol ),
115100 pub : make (chan * lp.Publish ),
116101 stop : make (chan interface {}, 1 ), // Buffered by 1 just to make it non-blocking
117102 service : s ,
@@ -311,7 +296,7 @@ func (c *_Conn) outboundID(mid message.MID) (id uint16) {
311296 return uint16 (uint32 (c .connid ) - (uint32 (mid )))
312297}
313298
314- func (c * _Conn ) storeInbound (m lp.Packet ) {
299+ func (c * _Conn ) storeInbound (m lp.LineProtocol ) {
315300 if c .clientid != nil {
316301 blockId := uint64 (c .clientid .Contract ())
317302 k := uint64 (c .inboundID (m .Info ().MessageID ))<< 32 + blockId
@@ -320,7 +305,7 @@ func (c *_Conn) storeInbound(m lp.Packet) {
320305 }
321306}
322307
323- func (c * _Conn ) storeOutbound (m lp.Packet ) {
308+ func (c * _Conn ) storeOutbound (m lp.LineProtocol ) {
324309 if c .clientid != nil {
325310 blockId := uint64 (c .clientid .Contract ())
326311 k := uint64 (c .inboundID (m .Info ().MessageID ))<< 32 + blockId
0 commit comments