codec

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSize int64 = headerKeySize + headerValueSize + headerChecksumSize + headerTTLSize // 24 byte
)

Variables

This section is empty.

Functions

func IsCorruptedData

func IsCorruptedData(err error) bool

Types

type Decoder

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

Decoder wraps an underlying io.Reader and allows you to stream Entry decodings on it.

func NewDecoder

func NewDecoder(ctx runtime.Context, r ReaderAtSeeker) *Decoder

NewDecoder creates a streaming Entry decoder.

func (*Decoder) Close

func (d *Decoder) Close()

func (*Decoder) Decode

func (d *Decoder) Decode() (*Payload, error)

Decode decodes the next Entry from the current stream

func (*Decoder) DecodeHeader

func (d *Decoder) DecodeHeader() (*Header, error)

type Encoder

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

Encoder wraps an underlying io.Writer and allows you to stream Entry encodings on it.

func NewEncoder

func NewEncoder(ctx runtime.Context, w io.Writer, tempDir string, copyTempThreshold int64) *Encoder

NewEncoder creates a streaming Entry encoder.

func (*Encoder) Close

func (e *Encoder) Close()

func (*Encoder) Encode

func (e *Encoder) Encode(key []byte, r io.Reader, expiry time.Time) (int64, error)

Encode takes any Entry and streams it to the underlying writer. Messages are framed with a key-length and value-length prefix.

func (*Encoder) Flush

func (e *Encoder) Flush() error
type Header struct {
	KeySize   int32
	ValueSize int64
	Checksum  uint32
	Expiry    time.Time
	N         int64
}

type Payload

type Payload struct {
	Key       []byte
	Value     io.Reader
	Checksum  uint32
	Expiry    time.Time
	N         int64
	ValueSize int64
	// contains filtered or unexported fields
}

func (*Payload) Close

func (p *Payload) Close() error

func (*Payload) Read

func (p *Payload) Read(buf []byte) (int, error)

type ReaderAtSeeker

type ReaderAtSeeker interface {
	io.Seeker
	io.ReaderAt
}

Jump to

Keyboard shortcuts

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