compression

package
v0.0.0-...-e2e6556 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GZIP_TYPE    = "gzip"
	ZLIB_TYPE    = "zlib"
	DEFLATE_TYPE = "deflate"
	SNAPPY_TYPE  = "snappy"
	ZSTD_TYPE    = "zstd"
)

Variables

View Source
var (
	ErrUnknownCompressionType = errors.New("unknown-compression-type")
)

Functions

func NewReader

func NewReader(compressionType string, reader io.Reader) (io.Reader, error)

func NewWriter

func NewWriter(compressionType string, writer io.Writer) (io.WriteCloser, error)

Types

type Compressor

type Compressor[I, O []byte] struct {
	// contains filtered or unexported fields
}

Compressor is a generic task capable of compress a []byte into zstd or gzip.

func NewCompressor

func NewCompressor[T, K []byte](compressionType string, logger *slog.Logger) *Compressor[T, K]

Creates a new Compressor task.

func (*Compressor[I, O]) Run

func (d *Compressor[I, O]) Run(_ context.Context, input I, meta map[string]interface{}, _ string) (O, error)

Run receives output from previous worker, calls adaptFn and compress it into selected format.

type Decompressor

type Decompressor[T, K []byte] struct {
	// contains filtered or unexported fields
}

Decompressor is a generic task capable of decompress []byte compressed with ZSTD or GZIP

func NewDecompressor

func NewDecompressor[I, O []byte](compressionType string, logger *slog.Logger) *Decompressor[I, O]

func (*Decompressor[I, O]) Run

func (d *Decompressor[I, O]) Run(_ context.Context, input I, meta map[string]interface{}, _ string) (O, error)

The return data from Run will be []byte decompressed

Jump to

Keyboard shortcuts

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