paxos

package
v0.0.0-...-6823d0b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeaderSlot       = "Slot"
	HTTPHeaderBallot     = "Ballot"
	HTTPHeaderExecute    = "Execute"
	HTTPHeaderInProgress = "Inprogress"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*paxi.HTTPClient
	// contains filtered or unexported fields
}

Client overwrites read operation for Paxos

func NewClient

func NewClient(id paxi.ID) *Client

func (*Client) Get

func (c *Client) Get(key paxi.Key) (paxi.Value, error)

Get implements paxi.Client interface there are three reading modes: (1) read as normal command (2) read from leader with current ballot number (3) read from quorum of replicas with barrier

func (*Client) Put

func (c *Client) Put(key paxi.Key, value paxi.Value) error

type CommandBallot

type CommandBallot struct {
	Command paxi.Command
	Ballot  paxi.Ballot
}

CommandBallot conbines each command with its ballot number

func (CommandBallot) String

func (cb CommandBallot) String() string

type P1a

type P1a struct {
	Ballot paxi.Ballot
}

P1a prepare message

func (P1a) String

func (m P1a) String() string

type P1b

type P1b struct {
	Ballot paxi.Ballot
	ID     paxi.ID               // from node id
	Log    map[int]CommandBallot // uncommitted logs
}

P1b promise message

func (P1b) String

func (m P1b) String() string

type P2a

type P2a struct {
	Ballot  paxi.Ballot
	Slot    int
	Command paxi.Command
}

P2a accept message

func (P2a) String

func (m P2a) String() string

type P2b

type P2b struct {
	Ballot paxi.Ballot
	ID     paxi.ID // from node id
	Slot   int
}

P2b accepted message

func (P2b) String

func (m P2b) String() string

type P3

type P3 struct {
	Ballot  paxi.Ballot
	Slot    int
	Command paxi.Command
}

P3 commit message

func (P3) String

func (m P3) String() string

type Paxos

type Paxos struct {
	paxi.Node

	Q1              func(*paxi.Quorum) bool
	Q2              func(*paxi.Quorum) bool
	ReplyWhenCommit bool
	// contains filtered or unexported fields
}

Paxos instance

func NewPaxos

func NewPaxos(n paxi.Node, options ...func(*Paxos)) *Paxos

NewPaxos creates new paxos instance

func (*Paxos) Ballot

func (p *Paxos) Ballot() paxi.Ballot

Ballot returns current ballot

func (*Paxos) HandleP1a

func (p *Paxos) HandleP1a(m P1a)

HandleP1a handles P1a message

func (*Paxos) HandleP1b

func (p *Paxos) HandleP1b(m P1b)

HandleP1b handles P1b message

func (*Paxos) HandleP2a

func (p *Paxos) HandleP2a(m P2a)

HandleP2a handles P2a message

func (*Paxos) HandleP2b

func (p *Paxos) HandleP2b(m P2b)

HandleP2b handles P2b message

func (*Paxos) HandleP3

func (p *Paxos) HandleP3(m P3)

HandleP3 handles phase 3 commit message

func (*Paxos) HandleRequest

func (p *Paxos) HandleRequest(r paxi.Request)

HandleRequest handles request and start phase 1 or phase 2

func (*Paxos) IsLeader

func (p *Paxos) IsLeader() bool

IsLeader indecates if this node is current leader

func (*Paxos) Leader

func (p *Paxos) Leader() paxi.ID

Leader returns leader id of the current ballot

func (*Paxos) P1a

func (p *Paxos) P1a()

P1a starts phase 1 prepare

func (*Paxos) P2a

func (p *Paxos) P2a(r *paxi.Request)

P2a starts phase 2 accept

func (*Paxos) SetActive

func (p *Paxos) SetActive(active bool)

SetActive sets current paxos instance as active leader

func (*Paxos) SetBallot

func (p *Paxos) SetBallot(b paxi.Ballot)

SetBallot sets a new ballot number

type Replica

type Replica struct {
	paxi.Node
	*Paxos
}

Replica for one Paxos instance

func NewReplica

func NewReplica(id paxi.ID) *Replica

NewReplica generates new Paxos replica

Jump to

Keyboard shortcuts

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