raftmdb

package module
v0.0.0-...-72c811a Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MPL-2.0 Imports: 8 Imported by: 72

README

raft-mdb Build Status

This repository provides the raftmdb package. The package exports the MDBStore 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 LMDB. LMDB has a number of advantages to other embedded databases includes transactions, MVCC, and lack of compaction.

The one disadvantage is because it is a C library, it requires the use of cgo which complicates cross compilation. For that reason, this is in a separate package from raft, so that clients can avoid cgo if they so choose.

Documentation

The documentation for this package can be found on Godoc here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MDBStore

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

MDBStore provides an implementation of LogStore and StableStore, all backed by a single MDB database.

func NewMDBStore

func NewMDBStore(base string) (*MDBStore, error)

NewMDBStore returns a new MDBStore and potential error. Requres a base directory from which to operate. Uses the default maximum size.

func NewMDBStoreWithSize

func NewMDBStoreWithSize(base string, maxSize uint64) (*MDBStore, error)

NewMDBStore returns a new MDBStore and potential error. Requres a base directory from which to operate, and a maximum size. If maxSize is not 0, a default value is used.

func (*MDBStore) Close

func (m *MDBStore) Close() error

Close is used to gracefully shutdown the MDB store

func (*MDBStore) DeleteRange

func (m *MDBStore) DeleteRange(minIdx, maxIdx uint64) error

Deletes a range of log entries. The range is inclusive.

func (*MDBStore) FirstIndex

func (m *MDBStore) FirstIndex() (uint64, error)

func (*MDBStore) Get

func (m *MDBStore) Get(key []byte) ([]byte, error)

Get a K/V pair

func (*MDBStore) GetLog

func (m *MDBStore) GetLog(index uint64, logOut *raft.Log) error

Gets a log entry at a given index

func (*MDBStore) GetUint64

func (m *MDBStore) GetUint64(key []byte) (uint64, error)

func (*MDBStore) LastIndex

func (m *MDBStore) LastIndex() (uint64, error)

func (*MDBStore) Set

func (m *MDBStore) Set(key []byte, val []byte) error

Set a K/V pair

func (*MDBStore) SetUint64

func (m *MDBStore) SetUint64(key []byte, val uint64) error

func (*MDBStore) StoreLog

func (m *MDBStore) StoreLog(log *raft.Log) error

Stores a log entry

func (*MDBStore) StoreLogs

func (m *MDBStore) StoreLogs(logs []*raft.Log) error

Stores multiple log entries

Jump to

Keyboard shortcuts

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