log

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogEntries

type LogEntries []LogEntry

LogEntries is a slice of LogEntry.

func (*LogEntries) AppendEntry

func (l *LogEntries) AppendEntry(entry LogEntry)

AppendEntry appends an entry to the log.

func (*LogEntries) GetEntries

func (l *LogEntries) GetEntries(minIndex, maxIndex uint64) LogEntries

GetEntries returns the entries between the given indexes.

func (*LogEntries) GetEntriesFromIndex

func (l *LogEntries) GetEntriesFromIndex(index uint64) LogEntries

GetEntriesFromIndex returns the entries from the given index.

func (*LogEntries) GetEntriesSlice

func (l *LogEntries) GetEntriesSlice(index uint64) []*LogEntry

GetEntriesSlice returns the entries between the given indexes.

func (LogEntries) GetLog

func (l LogEntries) GetLog(index uint64) LogEntry

GetLog returns the entry at the given index.

func (LogEntries) GetLogTerm

func (l LogEntries) GetLogTerm(index uint64) uint64

GetLogTerm returns the Term of the entry at the given index.

func (LogEntries) Last

func (l LogEntries) Last() *LogEntry

Last returns the last entry in the log.

func (LogEntries) LastCommand

func (l LogEntries) LastCommand() any

LastCommand returns the Command of the last entry in the log.

func (LogEntries) LastIndex

func (l LogEntries) LastIndex() uint64

func (LogEntries) LastSN

func (l LogEntries) LastSN() int64

LastSN returns the SN of the last entry in the log.

func (LogEntries) LastTerm

func (l LogEntries) LastTerm() uint64

LastTerm returns the Term of the last entry in the log.

func (LogEntries) Length

func (l LogEntries) Length() int

func (*LogEntries) MatchEntry

func (l *LogEntries) MatchEntry(prevLogIndex uint64, prevLogTerm uint64) bool

MatchEntry returns true if the given prevLogIndex and prevLogTerm match the log.

func (*LogEntries) StoreEntriesFromIndex

func (l *LogEntries) StoreEntriesFromIndex(index uint64, entries LogEntries)

StoreEntriesFromIndex stores the entries from the given index. If the existing entry conflicts with a new one (same index but different terms), delete the existing entry and all that follow it and append the new entries. If the new entry is not in the existing log, append it.

type LogEntry

type LogEntry struct {
	// Index is the index of the entry in the log.
	Index uint64
	// Term is the Term in which the entry was received by the leader.
	Term uint64
	// Command is the Command to be applied to the state machine.
	Command []byte
	// Sn is the serial number of the entry.
	Sn int64
}

LogEntry is a log entry.

func (*LogEntry) String

func (l *LogEntry) String() string

String returns a string representation of the log entry. We use a concatinated string of the Term and Command.

Jump to

Keyboard shortcuts

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