Documentation
¶
Overview ¶
Package blobcompress provides a somewhat implementation-agnostic mechanism for blobcompression and deblobcompression of an io.Reader. This is mainly intended to be used for blobcompressing tar layer blobs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = Gzip
Default is the default algorithm used within umoci if unspecified by a user.
Functions ¶
func MustRegisterAlgorithm ¶
func MustRegisterAlgorithm(algo Algorithm)
MustRegisterAlgorithm is like RegisterAlgorithm but it panics if RegisterAlgorithm returns an error. Intended for use in init functions.
Types ¶
type Algorithm ¶
type Algorithm interface {
// MediaTypeSuffix returns the name of the blobcompression algorithm. This name
// will be used when generating and parsing MIME type +-suffixes.
MediaTypeSuffix() string
// Compress sets up the streaming blobcompressor for this blobcompression type.
Compress(plain io.Reader) (blobcompressed io.ReadCloser, _ error)
// Deblobcompress sets up the streaming deblobcompressor for this blobcompression type.
Decompress(blobcompressed io.Reader) (plain io.ReadCloser, _ error)
}
Algorithm is a generic representation of a compression algorithm that can be used by umoci for compressing and decompressing layer blobs. If you create a custom algorithm, you should make sure you register it with RegisterAlgorithm so that layers using the algorithm can be decompressed.
var Gzip Algorithm = gzipAlgo{}
Gzip provides concurrent gzip blobcompression and deblobcompression.
var Noop Algorithm = noopAlgo{}
Noop does no compression.
var Zstd Algorithm = zstdAlgo{}
Zstd provides zstd blobcompression and deblobcompression.
func GetAlgorithm ¶
GetAlgorithm looks for a registered Algorithm with the given MediaTypeSuffix (which doubles as its name). Return nil if no such algorithm has been registered.