Documentation ¶
Index ¶
- type AcceptedValue
- type GossipState
- type Node
- type NodeClaims
- type NodeID
- type Observer
- func (observer *Observer) Consensus() (bool, AcceptedValue)
- func (observer *Observer) GossipState() GossipState
- func (observer *Observer) IsElector() bool
- func (observer *Observer) Propose()
- func (observer *Observer) SetQuorum(uint)
- func (observer *Observer) Think() bool
- func (observer *Observer) Update(from GossipState) bool
- type Participant
- type ProposalID
- type Status
- type Value
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 (*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) 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) Think ¶
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 ¶
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 ¶ added in v1.5.0
type Observer struct { }
func (*Observer) Consensus ¶ added in v1.5.0
func (observer *Observer) Consensus() (bool, AcceptedValue)
func (*Observer) GossipState ¶ added in v1.5.0
func (observer *Observer) GossipState() GossipState
func (*Observer) Update ¶ added in v1.5.0
func (observer *Observer) Update(from GossipState) bool
type Participant ¶ added in v1.5.0
type Participant interface { GossipState() GossipState Update(from GossipState) bool SetQuorum(uint) Propose() Think() bool Consensus() (bool, AcceptedValue) IsElector() bool }
func NewObserver ¶ added in v1.5.0
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