raftmdb

package module
v0.0.0-...-c4d1a57 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: MPL-2.0 Imports: 12 Imported by: 0

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 seperate 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 {
	// Determines how frequently the MDBStore will check for stale readers.
	// ReaderCheck is guaranteed to be called between any two updates more than
	// ReaderCheckPeriod apart.  If ReaderCheckPeriod is the MDBStore will only
	// check for stale readers while initializing.  ReaderCheckPeriod only
	// needs to be non-zero if other applications read from the backing
	// database concurrently.
	ReaderCheckPeriod time.Duration
	// 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 int64) (*MDBStore, error)

NewMDBStoreWithSize 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

DeleteRange deletes a range of log entries. The range is inclusive.

func (*MDBStore) FirstIndex

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

FirstIndex returns the first index in the MDBStore

func (*MDBStore) Get

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

Get returns the value for a given key.

func (*MDBStore) GetLog

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

GetLog gets a log entry at a given index

func (*MDBStore) GetUint64

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

GetUint64 returns the value of a key interpreted as a uint64 value.

func (*MDBStore) LastIndex

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

LastIndex returns the last index in the MDBStore

func (*MDBStore) Set

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

Set associates a key with a value.

func (*MDBStore) SetUint64

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

SetUint64 sets a key to a uint64 value.

func (*MDBStore) StoreLog

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

StoreLog stores a log entry

func (*MDBStore) StoreLogs

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

StoreLogs stores multiple log entries

Jump to

Keyboard shortcuts

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