storage

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package storage is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEntry   = errors.New("no entry")
	ErrBadEntry  = errors.New("bad entry")
	ErrCompacted = errors.New("appending entries has been compacted")
	ErrTruncated = errors.New("appending entries has been truncated")
)
View Source
var ErrClosed = errors.New("WAL: closed")

Functions

func ApplyKey

func ApplyKey(id uint64) string

func CommitKey

func CommitKey(id uint64) string

func CompactKey

func CompactKey(id uint64) string

func ConfStateKey

func ConfStateKey(id uint64) string

func HardStateKey

func HardStateKey(id uint64) string

Types

type AppendCallback

type AppendCallback = func(AppendResult, error)

type AppendResult

type AppendResult struct {
	Term  uint64
	Index uint64
}

type MockSnapshotOperator

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

MockSnapshotOperator is a mock of SnapshotOperator interface.

func NewMockSnapshotOperator

func NewMockSnapshotOperator(ctrl *gomock.Controller) *MockSnapshotOperator

NewMockSnapshotOperator creates a new mock instance.

func (*MockSnapshotOperator) ApplySnapshot

func (m *MockSnapshotOperator) ApplySnapshot(data []byte) error

ApplySnapshot mocks base method.

func (*MockSnapshotOperator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSnapshotOperator) GetSnapshot

func (m *MockSnapshotOperator) GetSnapshot(index uint64) ([]byte, error)

GetSnapshot mocks base method.

type MockSnapshotOperatorMockRecorder

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

MockSnapshotOperatorMockRecorder is the mock recorder for MockSnapshotOperator.

func (*MockSnapshotOperatorMockRecorder) ApplySnapshot

func (mr *MockSnapshotOperatorMockRecorder) ApplySnapshot(data interface{}) *gomock.Call

ApplySnapshot indicates an expected call of ApplySnapshot.

func (*MockSnapshotOperatorMockRecorder) GetSnapshot

func (mr *MockSnapshotOperatorMockRecorder) GetSnapshot(index interface{}) *gomock.Call

GetSnapshot indicates an expected call of GetSnapshot.

type SnapshotOperator

type SnapshotOperator interface {
	GetSnapshot(index uint64) ([]byte, error)
	ApplySnapshot(data []byte) error
}

type Storage

type Storage struct {

	// AppendExecutor is the Executor that executes Append, postAppend and Compact.
	AppendExecutor executor.Executor
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(
	ctx context.Context, nodeID vanus.ID, wal *WAL, stateStore *meta.SyncStore, hintStore *meta.AsyncStore,
	snapOp SnapshotOperator,
) (*Storage, error)

NewStorage creates an empty Storage.

func RecoverStorage

func RecoverStorage(
	nodeID vanus.ID, wal *WAL, stateStore *meta.SyncStore, hintStore *meta.AsyncStore, snapOp SnapshotOperator,
) (*Storage, error)

func (*Storage) Append

func (s *Storage) Append(ctx context.Context, entries []raftpb.Entry, cb AppendCallback)

Append appends the new entries to storage. After the call returns, all entries are readable. After the AppendCallback cb fires, all entries are persisted. NOTE: Synchronization is the responsibility of the caller.

func (*Storage) Applied

func (s *Storage) Applied() uint64

func (*Storage) ApplySnapshot

func (s *Storage) ApplySnapshot(ctx context.Context, snap raftpb.Snapshot) error

ApplySnapshot overwrites the contents of this Storage object with those of the given snapshot.

func (*Storage) Commit

func (s *Storage) Commit() uint64

func (*Storage) Compact

func (s *Storage) Compact(ctx context.Context, i uint64) error

Compact discards all log entries prior to compactIndex. It is the application's responsibility to not attempt to compact an index greater than raftLog.applied.

func (*Storage) Compacted

func (s *Storage) Compacted() uint64

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context)

Delete discard all data of Storage. NOTE: waiting for inflight append calls is the responsibility of the caller.

func (*Storage) Entries

func (s *Storage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)

Entries returns a slice of log entries in the range [lo,hi). MaxSize limits the total size of the log entries returned, but Entries returns at least one entry if any.

func (*Storage) FirstIndex

func (s *Storage) FirstIndex() (uint64, error)

FirstIndex returns the index of the first log entry that is possibly available via Entries (older entries have been incorporated into the latest Snapshot; if storage only contains the dummy entry the first log entry is not available).

func (*Storage) HardState

func (s *Storage) HardState() raftpb.HardState

HardState returns the saved HardState. NOTE: HardState.Commit will always be 0, don't use it.

func (*Storage) InitialState

func (s *Storage) InitialState() (raftpb.HardState, raftpb.ConfState, error)

InitialState returns the saved HardState and ConfState information.

func (*Storage) LastIndex

func (s *Storage) LastIndex() (uint64, error)

LastIndex returns the index of the last entry in the log.

func (*Storage) SetApplied

func (s *Storage) SetApplied(ctx context.Context, app uint64)

func (*Storage) SetCommit

func (s *Storage) SetCommit(ctx context.Context, commit uint64)

func (*Storage) SetConfState

func (s *Storage) SetConfState(ctx context.Context, cs raftpb.ConfState, cb meta.StoreCallback)

func (*Storage) SetHardState

func (s *Storage) SetHardState(ctx context.Context, hs raftpb.HardState, cb meta.StoreCallback)

SetHardState saves the current HardState.

func (*Storage) SetSnapshotOperator

func (ss *Storage) SetSnapshotOperator(op SnapshotOperator)

func (*Storage) Snapshot

func (s *Storage) Snapshot() (raftpb.Snapshot, error)

Snapshot returns the most recent snapshot. If snapshot is temporarily unavailable, it should return ErrSnapshotTemporarilyUnavailable, so raft state machine could know that Storage needs some time to prepare snapshot and call Snapshot later.

func (*Storage) Term

func (s *Storage) Term(i uint64) (uint64, error)

Term returns the term of entry i, which must be in the range [FirstIndex()-1, LastIndex()]. The term of the entry before FirstIndex is retained for matching purposes even though the rest of that entry may not be available.

type WAL

type WAL struct {
	*walog.WAL
	// contains filtered or unexported fields
}

func Recover

func Recover(
	ctx context.Context, dir string, stateStore *meta.SyncStore, hintStore *meta.AsyncStore, opts ...walog.Option,
) (map[vanus.ID]*Storage, *WAL, error)

func (*WAL) Close

func (w *WAL) Close()

func (*WAL) Wait

func (w *WAL) Wait()

Jump to

Keyboard shortcuts

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