diff --git a/Gopkg.lock b/Gopkg.lock index c627d58..2952949 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -17,22 +17,23 @@ branch = "master" name = "git.loafle.net/commons/rpc-go" packages = [ + "codec", "protocol", "protocol/json" ] - revision = "dcc3af07239b3f6fcbae3529bcb52c522b02053d" + revision = "b834f36e2bdb7e5ff93e83ab165ee0310895f6e7" [[projects]] branch = "master" name = "git.loafle.net/commons/server-go" packages = [ ".", - "client", "socket", + "socket/client", "socket/web", "socket/web/client" ] - revision = "1cae23cf7819d56fd399346a1dc30af6a82d1a93" + revision = "20a63b3de6efdc0942bfb4be21ddc64e2b76f59d" [[projects]] branch = "master" @@ -97,7 +98,7 @@ "server", "servlet" ] - revision = "1db82cb967f26a4cb4031e9fd8efe13031d1793c" + revision = "b7d6a6fcb39be4e5a376c6db4fd8fe7d6a2fe6bc" [[projects]] name = "github.com/BurntSushi/toml" @@ -133,8 +134,8 @@ "models", "pkg/escape" ] - revision = "89e084a80fb1e0bf5e7d38038e3367f821fdf3d7" - version = "v1.5.3" + revision = "4e4e00bc5ab85a3ff5e988c91020cf0399a87026" + version = "v1.5.4" [[projects]] name = "github.com/klauspost/compress" @@ -143,8 +144,8 @@ "gzip", "zlib" ] - revision = "6c8db69c4b49dd4df1fff66996cf556176d0b9bf" - version = "v1.2.1" + revision = "5fb1f31b0a61e9858f12f39266e059848a5f1cea" + version = "v1.3.0" [[projects]] name = "github.com/klauspost/cpuid" @@ -152,12 +153,6 @@ revision = "ae7887de9fa5d2db4eaa8174a7eff2c1ac00f2da" version = "v1.1" -[[projects]] - name = "github.com/klauspost/crc32" - packages = ["."] - revision = "cb6bfca970f6908083f26f39a79009d608efd5cd" - version = "v1.1" - [[projects]] branch = "master" name = "github.com/segmentio/kafka-go" @@ -210,7 +205,7 @@ "internal/timeseries", "trace" ] - revision = "db08ff08e8622530d9ed3a0e8ac279f6d4c02196" + revision = "4cb1c02c05b0e749b0365f61ae859a8e0cfceed9" [[projects]] name = "golang.org/x/text" @@ -237,7 +232,7 @@ branch = "master" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] - revision = "32ee49c4dd805befd833990acba36cb75042378c" + revision = "ff3583edef7de132f219f0efc00e097cabcc0ec0" [[projects]] name = "google.golang.org/grpc" @@ -280,6 +275,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "358adc51841b70f9d6056cdf8c5790f3c0870c94503977ff3dafdca7d9ff921d" + inputs-digest = "fedd80cb0ce2ca6815c9abe9cb0ccdc29e4636282126e3142a7f9d70f19a39b5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/config.json b/config.json index 4e08413..cc26a36 100644 --- a/config.json +++ b/config.json @@ -14,7 +14,8 @@ "pongTimeout": 60, "pingTimeout": 10, "pingPeriod": 9, - "enableCompression": false + "enableCompression": false, + "compressionThreshold": 8192 }, "external": { "grpc": { diff --git a/server/server.go b/server/server.go index cc1c079..0895cb6 100644 --- a/server/server.go +++ b/server/server.go @@ -1,6 +1,7 @@ package server import ( + crc "git.loafle.net/commons/rpc-go/codec" crpj "git.loafle.net/commons/rpc-go/protocol/json" cssw "git.loafle.net/commons/server-go/socket/web" "git.loafle.net/overflow/probe_gateway_rpc/config" @@ -8,7 +9,7 @@ import ( ) func New(_config *config.Config) *cssw.Server { - rpcServerCodec := crpj.NewServerCodec() + rpcServerCodec := crpj.NewCustomServerCodec(crc.NewCompressionCodecSelector(_config.ServerHandler.GetCompressionThreshold())) as := &servlet.AuthServlets{} as.RPCServerCodec = rpcServerCodec diff --git a/servlet/auth-servlet.go b/servlet/auth-servlet.go index 7553300..5939adc 100644 --- a/servlet/auth-servlet.go +++ b/servlet/auth-servlet.go @@ -13,7 +13,7 @@ import ( "git.loafle.net/commons/logging-go" "git.loafle.net/commons/server-go" - "git.loafle.net/commons/server-go/socket" + css "git.loafle.net/commons/server-go/socket" occn "git.loafle.net/overflow/commons-go/config/noauthprobe" ocmm "git.loafle.net/overflow/commons-go/model/meta" ocmn "git.loafle.net/overflow/commons-go/model/noauthprobe" @@ -165,7 +165,7 @@ func (s *AuthServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Req } } -func (s *AuthServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) { +func (s *AuthServlets) OnConnect(servletCtx server.ServletCtx, conn css.Conn) { s.RPCServlets.OnConnect(servletCtx, conn) _tempProbeKey := servletCtx.GetAttribute(og.SessionIDKey) @@ -216,8 +216,8 @@ LOOP: for _, session := range sessions { _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) if nil != _writeChan { - writeChan := _writeChan.(chan<- []byte) - writeChan <- *msg.Message + writeChan := _writeChan.(chan<- css.SocketMessage) + writeChan <- css.MakeSocketMessage(css.TextMessage, *msg.Message) } } } diff --git a/servlet/probe-servlet.go b/servlet/probe-servlet.go index 42177e0..18a7368 100644 --- a/servlet/probe-servlet.go +++ b/servlet/probe-servlet.go @@ -9,7 +9,7 @@ import ( "git.loafle.net/commons/logging-go" "git.loafle.net/commons/server-go" - "git.loafle.net/commons/server-go/socket" + css "git.loafle.net/commons/server-go/socket" occp "git.loafle.net/overflow/commons-go/config/probe" ocmp "git.loafle.net/overflow/commons-go/model/probe" oe "git.loafle.net/overflow/external-go" @@ -107,7 +107,7 @@ func (s *ProbeServlets) Handshake(servletCtx server.ServletCtx, ctx *fasthttp.Re return extHeader, nil } -func (s *ProbeServlets) OnConnect(servletCtx server.ServletCtx, conn socket.Conn) { +func (s *ProbeServlets) OnConnect(servletCtx server.ServletCtx, conn css.Conn) { s.RPCServlets.OnConnect(servletCtx, conn) _probeKey := servletCtx.GetAttribute(og.SessionIDKey) @@ -159,8 +159,8 @@ LOOP: for _, session := range sessions { _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) if nil != _writeChan { - writeChan := _writeChan.(chan<- []byte) - writeChan <- *msg.Message + writeChan := _writeChan.(chan<- css.SocketMessage) + writeChan <- css.MakeSocketMessage(css.TextMessage, *msg.Message) } }