raftleveldb

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2022 License: MPL-2.0 Imports: 8 Imported by: 5 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

raft-leveldb

This repository provides the raftleveldb package. The package exports the LevelDBStore which is an implementation of both a LogStore and StableStore.

It is meant to be used as a backend for the raft package here.

This implementation uses LevelDB. LevelDB is a simple key/value store implemented in pure Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("closed")

ErrClosed is returned when the log is closed

View Source
var ErrCorrupt = errors.New("corrupt")

ErrCorrupt is returned when the log is corrup

View Source
var ErrKeyNotFound = errors.New("not found")

ErrKeyNotFound is returned when a given key does not exist

Functions

This section is empty.

Types

type Level

type Level int

Level is the consistency level

const (
	Low    Level = -1
	Medium Level = 0
	High   Level = 1
)

Low, Medium, or High level

type LevelDBStore

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

LevelDBStore provides access to BoltDB for Raft to store and retrieve log entries. It also provides key/value storage, and can be used as a LogStore and StableStore.

func NewLevelDBStore

func NewLevelDBStore(path string, durability Level) (*LevelDBStore, error)

NewLevelDBStore takes a file path and returns a connected Raft backend.

func (*LevelDBStore) Close

func (b *LevelDBStore) Close() error

Close is used to gracefully close the DB connection.

func (*LevelDBStore) DeleteRange

func (b *LevelDBStore) DeleteRange(min, max uint64) error

DeleteRange is used to delete logs within a given range inclusively.

func (*LevelDBStore) FirstIndex

func (b *LevelDBStore) FirstIndex() (uint64, error)

FirstIndex returns the first known index from the Raft log.

func (*LevelDBStore) Get

func (b *LevelDBStore) Get(k []byte) ([]byte, error)

Get is used to retrieve a value from the k/v store by key

func (*LevelDBStore) GetLog

func (b *LevelDBStore) GetLog(idx uint64, log *raft.Log) error

GetLog is used to retrieve a log from BoltDB at a given index.

func (*LevelDBStore) GetUint64

func (b *LevelDBStore) GetUint64(key []byte) (uint64, error)

GetUint64 is like Get, but handles uint64 values

func (*LevelDBStore) LastIndex

func (b *LevelDBStore) LastIndex() (uint64, error)

LastIndex returns the last known index from the Raft log.

func (*LevelDBStore) Set

func (b *LevelDBStore) Set(k, v []byte) error

Set is used to set a key/value set outside of the raft log

func (*LevelDBStore) SetUint64

func (b *LevelDBStore) SetUint64(key []byte, val uint64) error

SetUint64 is like Set, but handles uint64 values

func (*LevelDBStore) StoreLog

func (b *LevelDBStore) StoreLog(log *raft.Log) error

StoreLog is used to store a single raft log

func (*LevelDBStore) StoreLogs

func (b *LevelDBStore) StoreLogs(logs []*raft.Log) error

StoreLogs is used to store a set of raft logs

Jump to

Keyboard shortcuts

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