From f3c6b55cf7da1b2ca97757504f3e391ed66e8f36 Mon Sep 17 00:00:00 2001 From: Gabriel Bueno Date: Wed, 10 Jul 2024 11:18:47 -0300 Subject: [PATCH] add code review suggestions --- pkg/utils/utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7806083..e8b87f0 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -73,6 +73,8 @@ func DecompressGZIP(compressedData []byte) (decompressedData []byte, err error) return decompressedData, nil } +// TODO: Both CompressWhenNeeded and DecompressWhenNeeded should be methods in TelemetryData + // TODO: check if it's worth trying to compress the data prior to compressing it (e.g: using entropy algorithms) // This would save some CPU usage client side // TODO: have telemetry data type be passed in as a parameter to further check if we should compress data and which algorithm to use (e.g: deflate or gzip) @@ -81,7 +83,8 @@ func CompressWhenNeeded(data []byte) (resultData []byte, compression *string, er var validStr string = "gzip" // check whether it's worth compressing - if len(data) <= 80 { + const MIN_SIZE_DATA_COMPRESSION = 80 + if len(data) <= MIN_SIZE_DATA_COMPRESSION { return data, nil, nil }