compressor

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GzipCompressionPolicy is constant for gzip compression algorithm.
	GzipCompressionPolicy = "gzip"
	// LzwCompressionPolicy is constant for lzw compression algorithm.
	LzwCompressionPolicy = "lzw"
	// ZlibCompressionPolicy is constant for zlib compression algorithm.
	ZlibCompressionPolicy = "zlib"

	// DefaultCompression is constant used for whether to compress the snapshots or not.
	DefaultCompression = false
	// DefaultCompressionPolicy is constant for default compression algorithm(only if compression is enabled).
	DefaultCompressionPolicy = "gzip"

	// UnCompressSnapshotExtension is used for snapshot suffix when compression is not enabled.
	UnCompressSnapshotExtension = ""
	// GzipCompressionExtension is used for snapshot suffix when compressionPolicy is gzip.
	GzipCompressionExtension = ".gz"
	// LzwCompressionExtension is used for snapshot suffix when compressionPolicy is lzw.
	LzwCompressionExtension = ".Z"
	// ZlibCompressionExtension is used for snapshot suffix when compressionPolicy is zlib.
	ZlibCompressionExtension = ".zlib"

	// LzwLiteralWidth is constant used as literal Width in lzw compressionPolicy.
	LzwLiteralWidth = 8 //[2,8]
)

Variables

This section is empty.

Functions

func CompressSnapshot

func CompressSnapshot(data io.ReadCloser, compressionPolicy string) (io.ReadCloser, error)

CompressSnapshot takes uncompressed data as input and compress the data according to Compression Policy and write the compressed data into one end of pipe.

func DecompressSnapshot

func DecompressSnapshot(data io.ReadCloser, compressionPolicy string) (io.ReadCloser, error)

DecompressSnapshot take compressed data and compressionPolicy as input and it decompresses the data according to compression Policy and return uncompressed data.

func GetCompressionSuffix

func GetCompressionSuffix(compressionEnabled bool, compressionPolicy string) (string, error)

GetCompressionSuffix returns the suffix for snapshot w.r.t Compression Policy if compression is not enabled, it will simply return UnCompressSnapshotExtension(empty string).

func IsSnapshotCompressed

func IsSnapshotCompressed(compressionSuffix string) (bool, string, error)

IsSnapshotCompressed is helpful in determining whether the snapshot is compressed or not. it will return boolean, compressionPolicy corresponding to compressionSuffix and error.

Types

type CompressionConfig

type CompressionConfig struct {
	Enabled           bool   `json:"enabled"`
	CompressionPolicy string `json:"policy,omitempty"`
}

CompressionConfig holds the compression configuration.

func NewCompressorConfig

func NewCompressorConfig() *CompressionConfig

NewCompressorConfig returns the compression config.

func (*CompressionConfig) AddFlags

func (c *CompressionConfig) AddFlags(fs *flag.FlagSet)

AddFlags adds the flags to flagset.

func (*CompressionConfig) Validate

func (c *CompressionConfig) Validate() error

Validate validates the compression Config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL