es_block

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorInvalidDataBlockSize = errors.New("invalid data block size")
)

Functions

This section is empty.

Types

type BlockError

type BlockError func(w BlockWriter, offset int64, err error)

type BlockFinisher

type BlockFinisher func(w BlockWriter, size int64)

type BlockReader

type BlockReader interface {
	// FileBlocks Returns offsets of the file.
	FileBlocks(path string) (offsets []int64, err error)

	// ReadBlock Returns block data.
	ReadBlock(path string, offset int64) (data []byte, isLastBlock bool, err error)
}

func NewPlainReader

func NewPlainReader(l esl.Logger, blockSize int) BlockReader

type BlockRequester

type BlockRequester func(w BlockWriter, offset, blockSize int64)

type BlockWriter

type BlockWriter interface {
	WriteBlock(data []byte, offset int64)

	// Abort abort operation and clean up resources, then send error report
	Abort(offset int64, err error)

	// Path file path to write
	Path() string

	// Wait for finish
	Wait()
}

type BlockWriterFactory

type BlockWriterFactory interface {
	// Open a file with the block size.
	Open(path string, fileSize int64, req BlockRequester, fin BlockFinisher, be BlockError) BlockWriter

	// Wait for finish all writers
	Wait()
}

BlockWriterFactory Creates the stateful BlockWriter instance for write data in blocks. BlockWriter requests subsequent blocks if the instance can handle multiple blocks.

func NewWriterFactory

func NewWriterFactory(l esl.Logger, batchSize int, blockSize int) BlockWriterFactory

type Reader

type Reader interface {
	// ReadBlock Read a block. isEof will be true when it's the last block of the source.
	// EOF will not return error.
	ReadBlock() (block []byte, isEof bool, err error)
}

func NewReader

func NewReader(r io.Reader, blockSize int) Reader

Jump to

Keyboard shortcuts

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