paxos

package
v0.0.0-...-9f00f78 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptedValue

type AcceptedValue struct {
	Value  Value
	Origin ProposalID
}

An AcceptedValue is a Value plus the proposal which originated that Value. The origin is not essential, but makes comparing AcceptedValues easy even if comparing Values is not.

type GossipState

type GossipState map[NodeID]NodeClaims

type Node

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

func NewNode

func NewNode(name mesh.PeerName, uid mesh.PeerUID, quorum uint) *Node

func (*Node) Consensus

func (node *Node) Consensus() (bool, AcceptedValue)

Has a consensus been reached, based on the known claims of other nodes?

func (*Node) GossipState

func (node *Node) GossipState() GossipState

func (*Node) IsElector

func (node *Node) IsElector() bool

func (*Node) Propose

func (node *Node) Propose()

Initiate a new proposal, i.e. the Paxos "Prepare" step. This is simply a matter of gossipping a new proposal that supersedes all others.

func (*Node) SetQuorum

func (node *Node) SetQuorum(quorum uint)

func (*Node) Think

func (node *Node) Think() bool

The heart of the consensus algorithm. Return true if we have changed our claims.

func (*Node) Update

func (node *Node) Update(from GossipState) bool

Update this node's information about what other nodes know. Returns true if we learned something new.

type NodeClaims

type NodeClaims struct {
	// The node promises not to accept a proposal with id less
	// than this.
	Promise ProposalID

	// The accepted proposal, if valid
	Accepted    ProposalID
	AcceptedVal AcceptedValue
}

type NodeID

type NodeID struct {
	Name mesh.PeerName
	UID  mesh.PeerUID
}

The node identifier. The use of the UID here is important: Paxos acceptors must not forget their promises, so it's important that a node does not restart and lose its Paxos state but claim to have the same ID.

type Observer

type Observer struct {
}

func (*Observer) Consensus

func (observer *Observer) Consensus() (bool, AcceptedValue)

func (*Observer) GossipState

func (observer *Observer) GossipState() GossipState

func (*Observer) IsElector

func (observer *Observer) IsElector() bool

func (*Observer) Propose

func (observer *Observer) Propose()

func (*Observer) SetQuorum

func (observer *Observer) SetQuorum(uint)

func (*Observer) Think

func (observer *Observer) Think() bool

func (*Observer) Update

func (observer *Observer) Update(from GossipState) bool

type Participant

type Participant interface {
	GossipState() GossipState
	Update(from GossipState) bool
	SetQuorum(uint)
	Propose()
	Think() bool
	Consensus() (bool, AcceptedValue)
	IsElector() bool
}

func NewObserver

func NewObserver() Participant

type ProposalID

type ProposalID struct {
	// round numbers begin at 1.  round 0 indicates an
	// uninitialized ProposalID, and precedes all other ProposalIDs
	Round    uint
	Proposer NodeID
}

note all fields exported in structs so we can Gob them

type Status

type Status struct {
	Elector    bool
	KnownNodes int
	Quorum     uint
}

func NewStatus

func NewStatus(node *Node) *Status

type Value

type Value []mesh.PeerName

For seeding IPAM, the value we want consensus on is a set of peer names

Jump to

Keyboard shortcuts

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