Documentation ¶
Overview ¶
Package raft provides a wrapper making a 'LogDB' appropriate for use as a 'LogStore' for the github.com/hashicorp/raft library.
Index ¶
- Variables
- type LogStore
- func (l *LogStore) DeleteRange(min, max uint64) error
- func (l *LogStore) FirstIndex() (uint64, error)
- func (l *LogStore) GetLog(index uint64, log *raft.Log) error
- func (l *LogStore) LastIndex() (uint64, error)
- func (l *LogStore) StoreLog(log *raft.Log) error
- func (l *LogStore) StoreLogs(logs []*raft.Log) error
- type NoncontiguousIndexError
- type NonincreasingIndexError
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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 ¶
FirstIndex returns the first index written. 0 for no entries.
type NoncontiguousIndexError ¶
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 ¶
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