raftlog

package
v0.0.0-...-1a6bc1e Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogEntryDirectoryName string = "log_entries"
	LogMetaFileName       string = "logmetainfo"
)

Variables

View Source
var ErrIndexBelowStartIndex = errors.New("given index is below start index")

Functions

This section is empty.

Types

type PeristentLogState

type PeristentLogState struct {
	LogSizeBytes uint64 `json:"logsizebytes"`
	StartIndex   uint64 `json:"startindex"`
	StartTerm    uint64 `json:"startterm"`
}

type RaftLog

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

RaftLog is the structure through which logging functinality can be accessed

func New

func New(logDirectory string) *RaftLog

New returns an initiated instance of RaftLog

func (*RaftLog) AppendEntry

func (rl *RaftLog) AppendEntry(en *pb.LogEntry) (index uint64, err error)

AppendEntry will write the entry provided and return the index of the entry and an error object if somethign went wrong

func (*RaftLog) DiscardAllLogEntries

func (rl *RaftLog) DiscardAllLogEntries(snapshotIndex, snapshotTerm uint64)

Used once a new snapshot has been reverted to

func (*RaftLog) DiscardLogEntriesAfter

func (rl *RaftLog) DiscardLogEntriesAfter(startIndex uint64) error

DiscardLogEntriesAfter discards an entry in the logs at startIndex and all logs after it

func (*RaftLog) DiscardLogEntriesBefore

func (rl *RaftLog) DiscardLogEntriesBefore(endIndex, endTerm uint64)

DiscardLogEntriesBefore discards an entry in the logs at endIndex and all logs before it

func (*RaftLog) GetEntriesSince

func (rl *RaftLog) GetEntriesSince(index uint64) (entries []*pb.Entry, err error)

GetEntriesSince returns a list of entries including and after the one at the given index, and an error object if something went wrong

func (*RaftLog) GetLogEntries

func (rl *RaftLog) GetLogEntries(index, maxCount uint64) (entries []*pb.Entry, err error)

GetLogEntries gets maxCount log entries starting from index. If there are less entries than maxCount it gets all of them until the end.

func (*RaftLog) GetLogEntry

func (rl *RaftLog) GetLogEntry(index uint64) (entry *pb.LogEntry, err error)

GetLogEntry will read an entry at the given index returning the protobuf and an error if something went wrong

func (*RaftLog) GetLogEntryUnsafe

func (rl *RaftLog) GetLogEntryUnsafe(index uint64) (entry *pb.LogEntry, err error)

func (*RaftLog) GetLogSizeBytes

func (rl *RaftLog) GetLogSizeBytes() uint64

func (*RaftLog) GetMostRecentIndex

func (rl *RaftLog) GetMostRecentIndex() uint64

GetMostRecentIndex returns the index of the last log entry

func (*RaftLog) GetMostRecentTerm

func (rl *RaftLog) GetMostRecentTerm() uint64

GetMostRecentTerm returns the term of the last log entry

func (*RaftLog) GetStartIndex

func (rl *RaftLog) GetStartIndex() uint64

func (*RaftLog) GetStartTerm

func (rl *RaftLog) GetStartTerm() uint64

Jump to

Keyboard shortcuts

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