blockcodecs

package
v0.0.0-...-984cbf5 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodedLen

func DecodedLen(in []byte) (int, error)

func NewEncoder

func NewEncoder(w io.Writer, codec Codec) io.WriteCloser

func NewEncoderBuffer

func NewEncoderBuffer(w io.Writer, codec Codec, bufferSize int) io.WriteCloser

func Register

func Register(c Codec)

Register new codec.

NOTE: update FindCodecByName description, after adding new codecs.

func RegisterAlias

func RegisterAlias(name string, c Codec)

Types

type Codec

type Codec interface {
	ID() CodecID
	Name() string

	DecodedLen(in []byte) (int, error)
	Encode(dst, src []byte) ([]byte, error)
	Decode(dst, src []byte) ([]byte, error)
}

func FindCodec

func FindCodec(id CodecID) Codec

func FindCodecByName

func FindCodecByName(name string) Codec

FindCodecByName returns codec by name.

Possible names:

null
snappy
zstd08_{level} - level is integer 1, 3 or 7.
zstd_{level} - level is integer 1, 3 or 7.

func ListCodecs

func ListCodecs() []Codec

type CodecID

type CodecID uint16

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates decoder that supports input in any of registered codecs.

func NewDecoderCodec

func NewDecoderCodec(r io.Reader, codec Codec) *Decoder

NewDecoderCodec creates decode that tries to decode input using provided codec.

func (*Decoder) Read

func (d *Decoder) Read(p []byte) (int, error)

func (*Decoder) SetCheckUnderlyingEOF

func (d *Decoder) SetCheckUnderlyingEOF(checkEOF bool)

SetCheckUnderlyingEOF changes EOF handling.

Blockcodecs format contains end of stream separator. By default Decoder will stop right after that separator, without trying to read following bytes from underlying reader.

That allows reading sequence of blockcodecs streams from one underlying stream of bytes, but messes up HTTP keep-alive, when using blockcodecs together with net/http connection pool.

Setting CheckUnderlyingEOF to true, changes that. After encoutering end of stream block, Decoder will perform one more Read from underlying reader and check for io.EOF.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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