From fcc9cfc38c1011419f42989b24a2b73f3cdcd0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 7 Jul 2022 13:35:25 +0100 Subject: [PATCH] feat(backend): use github.com/klauspost/compress for gzip --- cmd/karma/main.go | 2 +- cmd/karma/views.go | 2 +- go.mod | 1 + go.sum | 2 ++ internal/alertmanager/tls.go | 2 +- internal/uri/http.go | 2 +- internal/uri/uri_test.go | 2 +- 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/karma/main.go b/cmd/karma/main.go index 0714807ae..a85a2088b 100644 --- a/cmd/karma/main.go +++ b/cmd/karma/main.go @@ -1,7 +1,6 @@ package main import ( - "compress/flate" "context" "errors" "fmt" @@ -30,6 +29,7 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" lru "github.com/hashicorp/golang-lru" + "github.com/klauspost/compress/flate" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/zerolog" "github.com/rs/zerolog/log" diff --git a/cmd/karma/views.go b/cmd/karma/views.go index 6b988bea1..839697eb1 100644 --- a/cmd/karma/views.go +++ b/cmd/karma/views.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "compress/gzip" "encoding/base64" "encoding/json" "fmt" @@ -15,6 +14,7 @@ import ( "github.com/cnf/structhash" "github.com/fvbommel/sortorder" + "github.com/klauspost/compress/gzip" "github.com/prymitive/karma/internal/alertmanager" "github.com/prymitive/karma/internal/config" diff --git a/go.mod b/go.mod index 5d2865101..f22c20be2 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/google/go-cmp v0.5.8 github.com/hashicorp/golang-lru v0.5.4 github.com/jarcoal/httpmock v1.2.0 + github.com/klauspost/compress v1.15.7 github.com/knadh/koanf v1.4.2 github.com/mitchellh/mapstructure v1.5.0 github.com/pmezard/go-difflib v1.0.0 diff --git a/go.sum b/go.sum index f4c047fc6..81626396b 100644 --- a/go.sum +++ b/go.sum @@ -277,6 +277,8 @@ github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaR github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.15.7 h1:7cgTQxJCU/vy+oP/E3B9RGbQTgbiVzIJWIKOLoAsPok= +github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/knadh/koanf v1.4.2 h1:2itp+cdC6miId4pO4Jw7c/3eiYD26Z/Sz3ATJMwHxIs= github.com/knadh/koanf v1.4.2/go.mod h1:4NCo0q4pmU398vF9vq2jStF9MWQZ8JEDcDMHlDCr4h0= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= diff --git a/internal/alertmanager/tls.go b/internal/alertmanager/tls.go index 44ba11132..1726bb2a0 100644 --- a/internal/alertmanager/tls.go +++ b/internal/alertmanager/tls.go @@ -56,6 +56,6 @@ func NewHTTPTransport(caPath, certPath, keyPath string, insecureSkipVerify bool) } } - transport := http.Transport{TLSClientConfig: tlsConfig} + transport := http.Transport{TLSClientConfig: tlsConfig, DisableCompression: true} return &transport, nil } diff --git a/internal/uri/http.go b/internal/uri/http.go index 1dd7dbee9..a311625ab 100644 --- a/internal/uri/http.go +++ b/internal/uri/http.go @@ -1,11 +1,11 @@ package uri import ( - "compress/gzip" "fmt" "io" "net/http" + "github.com/klauspost/compress/gzip" "github.com/rs/zerolog/log" ) diff --git a/internal/uri/uri_test.go b/internal/uri/uri_test.go index 77d6a86c5..33226c363 100644 --- a/internal/uri/uri_test.go +++ b/internal/uri/uri_test.go @@ -2,7 +2,6 @@ package uri_test import ( "bytes" - "compress/gzip" "crypto/tls" "crypto/x509" "errors" @@ -12,6 +11,7 @@ import ( "testing" "time" + "github.com/klauspost/compress/gzip" "github.com/rs/zerolog" "github.com/prymitive/karma/internal/uri"