diff options
author | Valery Piashchynski <[email protected]> | 2021-06-05 21:28:09 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-05 21:28:09 +0300 |
commit | 7995c44d47075cca01c44120e5617d1d90b2a039 (patch) | |
tree | 83f9c35ff54945bd8173d0e7201234d17341007c | |
parent | d0ec24066b5fbb4e3accc9c45f72f7c638b35dba (diff) |
- Switch to better gzip middleware (performance)
- Use EXISTS to check of the particular topic exists in the redis
cluster instead of SMEMBERS
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | plugins/gzip/plugin.go | 4 | ||||
-rw-r--r-- | plugins/redis/plugin.go | 6 |
4 files changed, 8 insertions, 7 deletions
@@ -3,7 +3,6 @@ module github.com/spiral/roadrunner/v2 go 1.16 require ( - github.com/NYTimes/gziphandler v1.1.1 github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect github.com/alicebob/miniredis/v2 v2.14.5 github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b @@ -17,7 +16,7 @@ require ( github.com/google/flatbuffers v2.0.0+incompatible github.com/google/uuid v1.2.0 github.com/json-iterator/go v1.1.11 - github.com/klauspost/compress v1.12.2 // indirect + github.com/klauspost/compress v1.13.0 // indirect github.com/olekukonko/tablewriter v0.0.5 github.com/prometheus/client_golang v1.10.0 github.com/savsgio/gotils v0.0.0-20210316171653-c54912823645 // indirect @@ -233,6 +233,8 @@ github.com/klauspost/compress v1.11.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8= github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.0 h1:2T7tUoQrQT+fQWdaY5rjWztFGAFwbGD04iPJg90ZiOs= +github.com/klauspost/compress v1.13.0/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= diff --git a/plugins/gzip/plugin.go b/plugins/gzip/plugin.go index 24b125fb..a957878c 100644 --- a/plugins/gzip/plugin.go +++ b/plugins/gzip/plugin.go @@ -3,7 +3,7 @@ package gzip import ( "net/http" - "github.com/NYTimes/gziphandler" + "github.com/klauspost/compress/gzhttp" ) const PluginName = "gzip" @@ -17,7 +17,7 @@ func (g *Plugin) Init() error { func (g *Plugin) Middleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - gziphandler.GzipHandler(next).ServeHTTP(w, r) + gzhttp.GzipHandler(next).ServeHTTP(w, r) }) } diff --git a/plugins/redis/plugin.go b/plugins/redis/plugin.go index 7b5721f4..b2603a40 100644 --- a/plugins/redis/plugin.go +++ b/plugins/redis/plugin.go @@ -164,14 +164,14 @@ func (p *Plugin) Unsubscribe(connectionID string, topics ...string) error { for i := 0; i < len(topics); i++ { // if there are no such topics, we can safely unsubscribe from the redis - ssc := p.universalClient.SMembers(context.Background(), topics[i]) - res, err := ssc.Result() + exists := p.universalClient.Exists(context.Background(), topics[i]) + res, err := exists.Result() if err != nil { return err } // if we have associated connections - skip - if len(res) > 0 { + if res == 1 { // exists means that topic still exists and some other nodes may have connections associated with it continue } |