summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-05 21:28:09 +0300
committerValery Piashchynski <[email protected]>2021-06-05 21:28:09 +0300
commit7995c44d47075cca01c44120e5617d1d90b2a039 (patch)
tree83f9c35ff54945bd8173d0e7201234d17341007c /plugins
parentd0ec24066b5fbb4e3accc9c45f72f7c638b35dba (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]>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gzip/plugin.go4
-rw-r--r--plugins/redis/plugin.go6
2 files changed, 5 insertions, 5 deletions
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
}