quorum

package
Version: v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AckedIndexer

type AckedIndexer interface {
	AckedIndex(voterID uint64) (idx Index, found bool)
}

AckedIndexer allows looking up a commit index for a given ID of a voter from a corresponding MajorityConfig.

type Index

type Index uint64

Index is a Raft log position.

func (Index) String

func (i Index) String() string

type JointConfig

type JointConfig [2]MajorityConfig

JointConfig is a configuration of two groups of (possibly overlapping) majority configurations. Decisions require the support of both majorities.

func (JointConfig) CommittedIndex

func (c JointConfig) CommittedIndex(l AckedIndexer) Index

CommittedIndex returns the largest committed index for the given joint quorum. An index is jointly committed if it is committed in both constituent majorities.

func (JointConfig) Describe

func (c JointConfig) Describe(l AckedIndexer) string

Describe returns a (multi-line) representation of the commit indexes for the given lookuper.

func (JointConfig) IDs

func (c JointConfig) IDs() map[uint64]struct{}

IDs returns a newly initialized map representing the set of voters present in the joint configuration.

func (JointConfig) String

func (c JointConfig) String() string

func (JointConfig) VoteResult

func (c JointConfig) VoteResult(votes map[uint64]bool) VoteResult

VoteResult takes a mapping of voters to yes/no (true/false) votes and returns a result indicating whether the vote is pending, lost, or won. A joint quorum requires both majority quorums to vote in favor.

type MajorityConfig

type MajorityConfig map[uint64]struct{}

MajorityConfig is a set of IDs that uses majority quorums to make decisions.

func (MajorityConfig) CommittedIndex

func (c MajorityConfig) CommittedIndex(l AckedIndexer) Index

CommittedIndex computes the committed index from those supplied via the provided AckedIndexer (for the active config).

func (MajorityConfig) Describe

func (c MajorityConfig) Describe(l AckedIndexer) string

Describe returns a (multi-line) representation of the commit indexes for the given lookuper.

func (MajorityConfig) Slice

func (c MajorityConfig) Slice() []uint64

Slice returns the MajorityConfig as a sorted slice.

func (MajorityConfig) String

func (c MajorityConfig) String() string

func (MajorityConfig) VoteResult

func (c MajorityConfig) VoteResult(votes map[uint64]bool) VoteResult

VoteResult takes a mapping of voters to yes/no (true/false) votes and returns a result indicating whether the vote is pending (i.e. neither a quorum of yes/no has been reached), won (a quorum of yes has been reached), or lost (a quorum of no has been reached).

type VoteResult

type VoteResult uint8

VoteResult indicates the outcome of a vote.

const (
	// VotePending indicates that the decision of the vote depends on future
	// votes, i.e. neither "yes" or "no" has reached quorum yet.
	VotePending VoteResult = 1 + iota
	// VoteLost indicates that the quorum has voted "no".
	VoteLost
	// VoteWon indicates that the quorum has voted "yes".
	VoteWon
)

func (VoteResult) String

func (i VoteResult) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL