election

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election map[uint32]bool

Election objects keep track of the outcome of a single leader election by mapping remote peers to the votes they've provided. Uses simple majority to determine if an election has passed or failed.

func New

func New(peers ...uint32) Election

New creates an election for the specified peers, defaulting the votes to false until otherwise updated. Elections only allow the peers specified to vote.

func (Election) Majority

func (e Election) Majority() int

Majority computes how many nodes are needed for an election to pass.

func (Election) Passed

func (e Election) Passed() bool

Passed returns true if the number of True votes is a majority.

func (Election) Vote

func (e Election) Vote(pid uint32, vote bool)

Vote records the vote for the given Replica, identified by name.

func (Election) Votes

func (e Election) Votes() int

Votes sums the number of Ballots equal to true

Jump to

Keyboard shortcuts

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