compress

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package compress provides Zstd compression middleware for Trove. It compresses data on write and decompresses on read, with configurable minimum size thresholds and skip lists for already-compressed formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compress

type Compress struct {
	// contains filtered or unexported fields
}

Compress provides Zstd compression middleware.

func New

func New(opts ...Option) *Compress

New creates a new compression middleware.

func (*Compress) Direction

func (c *Compress) Direction() middleware.Direction

Direction returns ReadWrite since compression participates in both paths.

func (*Compress) Name

func (c *Compress) Name() string

Name returns the middleware identifier.

func (*Compress) WrapReader

func (c *Compress) WrapReader(_ context.Context, r io.ReadCloser, _ *driver.ObjectInfo) (io.ReadCloser, error)

WrapReader wraps a reader to decompress data on read. It detects the zstd magic bytes to determine if decompression is needed.

func (*Compress) WrapWriter

func (c *Compress) WrapWriter(_ context.Context, w io.WriteCloser, key string) (io.WriteCloser, error)

WrapWriter wraps a writer to compress data before writing. Data is buffered, then compressed and written on Close.

type Option

type Option func(*Compress)

Option configures the Compress middleware.

func WithExclude

func WithExclude(extensions ...string) Option

WithExclude adds file extensions to skip (already compressed formats).

func WithMinSize

func WithMinSize(size int64) Option

WithMinSize sets the minimum object size to compress. Objects smaller than this are passed through uncompressed.

Jump to

Keyboard shortcuts

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