paxos

package
v0.0.0-...-fe73bcc Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 2 Imported by: 1

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

type Ballot struct {
	Ts  uint64 // Timestamp
	Pid string // Process id
}

Ballot is a Paxos ballot containing a logical clock and the process id.

func (*Ballot) Equals

func (b *Ballot) Equals(to *Ballot) bool

Equals reports whether the ballot is equal "to" ballot.

func (*Ballot) Less

func (b *Ballot) Less(from *Ballot) bool

Less reports whether the ballot is less than the "from" ballot.

func (*Ballot) String

func (b *Ballot) String() string

String returns string representation of a ballot.

type Ballots

type Ballots []*Ballot

Ballots is a set of ballots.

func (Ballots) Len

func (b Ballots) Len() int

Len is the number of ballots in the set.

func (Ballots) Less

func (b Ballots) Less(i, j int) bool

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.

func (*Ballots) Push

func (b *Ballots) Push(x interface{})

Push pushes a ballot at the end of the ballots heap.

func (Ballots) Swap

func (b Ballots) Swap(i, j int)

Swap swaps the ballots with indexes i and j.

type Decided

type Decided struct {
	Ballot *Ballot
	Val    interface{} // The associated value
}

Decided message to broadcast the decided value

type Nack

type Nack struct {
	Ballot *Ballot
}

Nack is a NotOK acknowledgement

type Prepare

type Prepare struct {
	Ballot *Ballot
}

Prepare request

type Promise

type Promise struct {
	Ballot   *Ballot
	Accepted *Ballot
	Val      interface{} // The associated value
}

Promise response to a Prepare request

Directories

Path Synopsis
Package basic implements single decree paxos algorithm.
Package basic implements single decree paxos algorithm.

Jump to

Keyboard shortcuts

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