paxos

package module
v0.0.0-...-c06c2c1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: MIT Imports: 2 Imported by: 0

README

paxos

GitHub license GoDoc

It is the Paxos Consensus algorithm Paxos implement in Golang.

Inspired By:

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

Documentation

Overview

Package Paxos is a implement for consensus protocol algorithm "Paxos". The interface of this package is experimental and may change.

There are three role play in this algorithm: "Acceptor", "Proposer" and "Learner".

Index

Constants

View Source
const (
	Prepare msgType = iota + 1 // Send from proposer -> acceptor
	Promise                    // Send from acceptor -> proposer
	Propose                    // Send from proposer -> acceptor
	Accept                     // Send from acceptor -> learner
)

Variables

This section is empty.

Functions

func CreateNetwork

func CreateNetwork(nodes ...int) *network

func NewAcceptor

func NewAcceptor(id int, nt nodeNetwork, learners ...int) acceptor

Create a accetor and also assign learning IDs into acceptor. Acceptor: Will response request from proposer, promise the first and largest seq number propose.

After proposer reach the majority promise.  Acceptor will pass the proposal value to learner to confirn and choose.

func NewLearner

func NewLearner(id int, nt nodeNetwork, acceptorIDs ...int) *learner

Initilize learner and prepare message pool.

func NewProposer

func NewProposer(id int, val string, nt nodeNetwork, accetors ...int) *proposer

Types

This section is empty.

Jump to

Keyboard shortcuts

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