raft

package
v0.0.0-...-106869f Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package raft provides a wrapper making a 'LogDB' appropriate for use as a 'LogStore' for the github.com/hashicorp/raft library.

Index

Constants

This section is empty.

Variables

View Source
var ErrDeleteRange = errors.New("entries can only be deleted from the start or end")

ErrDeleteRange is returned when attempting to delete a range from the middle of the database.

View Source
var ErrZeroIndex = errors.New("zero is not a valid log index")

ErrZeroIndex is returned when attempting to insert a zero-indexed log entry to an empty database.

Functions

This section is empty.

Types

type LogStore

type LogStore struct {
	// Reference to the underlying log database. It is assumed that the 'LogStore' is the only user of
	// this 'LogDB'.
	logdb.LogDB
	// contains filtered or unexported fields
}

LogStore is implements the hashicorp/raft 'LogStore' interface, with the backing store being a 'LogDB'.

func New

func New(db logdb.LogDB) (*LogStore, error)

New creates a 'LogStore' backed by the given 'LogDB'. Log entries are encoded with messagepack.

The returned 'LogStore' assumes that it is the only user of the underlying 'LogDB', if this assumption does not hold then inconsistent results may arise.

If an error is returned, the log store could not be read. This shouldn't happen if it was opened successfully, but you never know.

func (*LogStore) DeleteRange

func (l *LogStore) DeleteRange(min, max uint64) error

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

This makes use of the fact that this can be turned into a Forget or Rollback: deletion is always from one end.

func (*LogStore) FirstIndex

func (l *LogStore) FirstIndex() (uint64, error)

FirstIndex returns the first index written. 0 for no entries.

func (*LogStore) GetLog

func (l *LogStore) GetLog(index uint64, log *raft.Log) error

GetLog gets a log entry at a given index.

func (*LogStore) LastIndex

func (l *LogStore) LastIndex() (uint64, error)

LastIndex returns the last index written. 0 for no entries.

func (*LogStore) StoreLog

func (l *LogStore) StoreLog(log *raft.Log) error

StoreLog stores a log entry.

func (*LogStore) StoreLogs

func (l *LogStore) StoreLogs(logs []*raft.Log) error

StoreLogs stores multiple log entries.

type NoncontiguousIndexError

type NoncontiguousIndexError struct {
	PriorIndex uint64
	GivenIndex uint64
}

A NoncontiguousIndexError is returned when attempting to insert a log entry with an index more than one greater than the last entry.

func (*NoncontiguousIndexError) Error

func (e *NoncontiguousIndexError) Error() string

type NonincreasingIndexError

type NonincreasingIndexError struct {
	PriorIndex uint64
	GivenIndex uint64
}

A NonincreasingIndexError is returned when attempting to insert a log entry with an index not greater than the last entry.

func (*NonincreasingIndexError) Error

func (e *NonincreasingIndexError) Error() string

Jump to

Keyboard shortcuts

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