Documentation ¶
Overview ¶
Package paxos implements different variants of paxos algorithm.
Example ¶
package main import ( "container/heap" "fmt" "github.com/armen/dp/consensus/paxos" ) func main() { ballots := paxos.Ballots{ &paxos.Ballot{2, "abc"}, &paxos.Ballot{1, "abc"}, &paxos.Ballot{2, "def"}, } heap.Init(&ballots) fmt.Println("Max ballot:", ballots[0]) for ballots.Len() > 0 { b := heap.Pop(&ballots).(*paxos.Ballot) fmt.Println(b) } }
Output: Max ballot: (2, "def") (2, "def") (2, "abc") (1, "abc")
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accept ¶
type Accept struct { Ballot *Ballot Val interface{} // The associated value }
Accept request
type Accepted ¶
type Accepted struct { Ballot *Ballot Val interface{} // The associated value }
Accepted response to an Accept request
type Ballot ¶
Ballot is a Paxos ballot containing a logical clock and the process id.
type Ballots ¶
type Ballots []*Ballot
Ballots is a set of ballots.
func (Ballots) Less ¶
Less reports whether the ballot with index i should sort before the ballot with index j.
func (*Ballots) Pop ¶
func (b *Ballots) Pop() interface{}
Pop removes the maximum ballot from the heap.
Click to show internal directories.
Click to hide internal directories.