Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move compression utilities into separate package #14167

Merged
merged 5 commits into from
Sep 19, 2024

Conversation

chaudum
Copy link
Contributor

@chaudum chaudum commented Sep 18, 2024

What this PR does / why we need it:

Compression tooling has been part of the chunkenc (chunk encoding)
package in the past for legacy reasons.

Since more components use this now, it's easier to keep it in a separate
package. This also eliminates the confusion around "encoding", since
this has been incorrectly used synonymously with "compression" in the past.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

Signed-off-by: Christian Haudum christian.haudum@gmail.com

@chaudum chaudum requested a review from a team as a code owner September 18, 2024 13:48
@chaudum chaudum force-pushed the chaudum/compression-package branch 4 times, most recently from 01ef96d to 2f061c9 Compare September 18, 2024 16:00
@chaudum chaudum changed the title chore: Move compression tooling into separate package chore: Move compression utilities into separate package Sep 18, 2024
Compression tooling has been part of the chunkenc (chunk encoding)
package in the past for legacy reasons.

Since more components use this now, it's easier to keep it in a separate
package. This also eliminates the confusion around "encoding", since
this has been incorrectly used synonymously with "compression" in the past.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
pkg/compression/encoding.go Outdated Show resolved Hide resolved
Comment on lines 49 to 70
switch enc {
case EncGZIP:
return &Gzip
case EncLZ4_64k:
return &Lz4_64k
case EncLZ4_256k:
return &Lz4_256k
case EncLZ4_1M:
return &Lz4_1M
case EncLZ4_4M:
return &Lz4_4M
case EncSnappy:
return &Snappy
case EncNone:
return &Noop
case EncFlate:
return &Flate
case EncZstd:
return &Zstd
default:
panic("unknown encoding")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: None* of the pools are referenced directly outside of this package, so it's safe to unexport all of them and just leave GetReaderPool/GetWriterPool as the public API for pools.

Personally I'm normally a fan of unexporting as much as possible as it reduces the surface where good API documentation is necessary. I don't feel too strongly about this at the moment, so I don't mind if this doesn't get changed.

*: compression.Gzip is referenced a few times, but all references can be replaced with compression.GetReaderPool(compression.EncGZIP) or compression.GetWriterPool(compression.EncGZIP).

}
}

// GzipPool is a gun zip compression pool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is gun zip a typo?

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(two small extra comments)

pkg/compression/encoding.go Outdated Show resolved Hide resolved
pkg/compression/encoding.go Outdated Show resolved Hide resolved
chaudum and others added 4 commits September 19, 2024 08:38
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
@chaudum chaudum merged commit 9637790 into main Sep 19, 2024
62 checks passed
@chaudum chaudum deleted the chaudum/compression-package branch September 19, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants