diff --git a/Makefile b/Makefile index 99a0ea730f..90a677a7b5 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,7 @@ docker-image/pyroscope/build: frontend/build go/bin docker-image/pyroscope/push: GOOS=linux docker-image/pyroscope/push: GOARCH=amd64 docker-image/pyroscope/push: frontend/build go/bin - $(call docker_buildx,--push) + $(call docker_buildx,--push,) define UPDATER_CONFIG_JSON { diff --git a/pkg/api/connect/compression.go b/pkg/api/connect/compression.go new file mode 100644 index 0000000000..83d83c72e3 --- /dev/null +++ b/pkg/api/connect/compression.go @@ -0,0 +1,33 @@ +package connectapi + +import ( + "io" + + "connectrpc.com/connect" + "github.com/klauspost/compress/gzip" +) + +const ( + compressionGzip = "gzip" +) + +var ( + gzipPoolHandler = connect.WithCompression( + compressionGzip, + func() connect.Decompressor { return &gzip.Reader{} }, + func() connect.Compressor { return gzip.NewWriter(io.Discard) }, + ) + gzipPoolClient = connect.WithAcceptCompression( + compressionGzip, + func() connect.Decompressor { return &gzip.Reader{} }, + func() connect.Compressor { return gzip.NewWriter(io.Discard) }, + ) +) + +func WithGzipHandler() connect.HandlerOption { + return gzipPoolHandler +} + +func WithGzipClient() connect.ClientOption { + return gzipPoolClient +} diff --git a/pkg/api/connect/connect.go b/pkg/api/connect/connect.go index aa0399ec37..bb17db6266 100644 --- a/pkg/api/connect/connect.go +++ b/pkg/api/connect/connect.go @@ -7,11 +7,13 @@ import ( func DefaultClientOptions() []connect.ClientOption { return []connect.ClientOption{ connect.WithCodec(ProtoCodec), + WithGzipClient(), } } func DefaultHandlerOptions() []connect.HandlerOption { return []connect.HandlerOption{ connect.WithCodec(ProtoCodec), + WithGzipHandler(), } }