raftchunking

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MPL-2.0 Imports: 11 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTermMismatch = errors.New("term mismatch during reconstruction of chunks, please resubmit")

	ErrInvalidOpNum = errors.New("no op num found when reconstructing chunks")

	ErrNoExistingChunks = errors.New("no existing chunks but non-zero sequence num")

	ErrSequenceNumberMismatch = errors.New("sequence number skipped")

	ErrMissingChunk = errors.New("missing sequence number during reconstruction")
)

Functions

func ChunkingApply

func ChunkingApply(cmd, extensions []byte, timeout time.Duration, applyFunc ApplyFunc) raft.ApplyFuture

ChunkingApply takes in a byte slice and chunks into raft.SuggestedMaxDataSize (or less if EOF) chunks, calling Apply on each. It requires a corresponding wrapper around the FSM to handle reconstructing on the other end. Timeout will be the timeout for each individual operation, not total. The return value is a future whose Error() will return only when all underlying Apply futures have had Error() return. Note that any error indicates that the entire operation will not be applied, assuming the correct FSM wrapper is used. If extensions is passed in, it will be set as the Extensions value on the Apply once all chunks are received.

Types

type ApplyFunc

type ApplyFunc func(raft.Log, time.Duration) raft.ApplyFuture

type ChunkingFSM

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

func NewChunkingFSM

func NewChunkingFSM(underlying raft.FSM) *ChunkingFSM

func (*ChunkingFSM) Apply

func (c *ChunkingFSM) Apply(l *raft.Log) interface{}

Apply applies the log, handling chunking as needed. The return value will either be an error or whatever is returned from the underlying Apply.

func (*ChunkingFSM) Restore

func (c *ChunkingFSM) Restore(rc io.ReadCloser) error

func (*ChunkingFSM) Snapshot

func (c *ChunkingFSM) Snapshot() (raft.FSMSnapshot, error)

func (*ChunkingFSM) Underlying

func (c *ChunkingFSM) Underlying() raft.FSM

Note: this is used in tests via the Raft package test helper functions, even if it's not used in client code

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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