Documentation ¶
Overview ¶
Package consensus implements the core of the Ios consensus algorithm. Package consensus is pure and does not perform any of its own IO operations such as writing to disk or sending packets. It is uses msgs.Io for this purpose.
Index ¶
- func Init(peerNet *msgs.PeerNet, clientNet *msgs.ClientNet, config Config, ...)
- func Recover(peerNet *msgs.PeerNet, clientNet *msgs.ClientNet, config Config, view int, ...)
- type Config
- type ConfigAll
- type ConfigCoordinator
- type ConfigInterfacer
- type ConfigMaster
- type ConfigParticipant
- type Log
- func (l *Log) AddEntries(startIndex int, endIndex int, entries []msgs.Entry)
- func (l *Log) AddEntry(index int, entry msgs.Entry)
- func (l *Log) GetEntries(startIndex int, endIndex int) []msgs.Entry
- func (l *Log) GetEntriesFrom(startIndex int) []msgs.Entry
- func (l *Log) GetEntry(index int) msgs.Entry
- func (l *Log) ImplicitCommit(windowSize int, commitIndex int)
- type QuorumSys
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(peerNet *msgs.PeerNet, clientNet *msgs.ClientNet, config Config, app *app.StateMachine, fail *msgs.FailureNotifier, storage msgs.Storage)
Init runs a fresh instance of the consensus algorithm. The caller is requried to process Io requests using msgs.Io It will not return until the application is terminated.
func Recover ¶
func Recover(peerNet *msgs.PeerNet, clientNet *msgs.ClientNet, config Config, view int, log *Log, app *app.StateMachine, snapshotIndex int, fail *msgs.FailureNotifier, storage msgs.Storage)
Recover restores an instance of the consensus algorithm. The caller is requried to process Io requests using msgs.Io It will not return until the application is terminated.
Types ¶
type Config ¶
type Config struct { All ConfigAll Master ConfigMaster Coordinator ConfigCoordinator Participant ConfigParticipant Interfacer ConfigInterfacer }
Config describes the static configuration of the consensus algorithm
type ConfigCoordinator ¶
type ConfigInterfacer ¶
type ConfigMaster ¶
type ConfigMaster struct { BatchInterval int // how often to batch process request in ms, 0 means no batching MaxBatch int // maximum requests in a batch, unused if BatchInterval=0 DelegateReplication int // how many replication coordinators to delegate to when master IndexExclusivity bool // if enabled, Ios will assign each index to at most one request }
type ConfigParticipant ¶
type Log ¶
type Log struct { LogEntries []msgs.Entry // contents of log, indexed from 0 to maxLength - 1 LastIndex int // greatest absolute index in log with entry, -1 means that the log has no entries AbsoluteIndex int // absolute index of first index in log // contains filtered or unexported fields }
Log holds the replication log used of Ios. Only indexes between AbsoluteIndex and (AbsoluteIndex + maxLength -1) are accessible Do not access LogEntries direct, always use AddEntry and AddEntries functions
func RestoreLog ¶
func (*Log) AddEntries ¶
func (*Log) ImplicitCommit ¶
ImplicitCommit will marked any uncommitted entries after commitIndex as committed if they are out-of-window and of the same view