raft

package
v0.0.0-...-03a7547 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSMSnapshot

type FSMSnapshot struct {
}

func (*FSMSnapshot) Persist

func (f *FSMSnapshot) Persist(sink raft.SnapshotSink) error

func (*FSMSnapshot) Release

func (f *FSMSnapshot) Release()

type OptionFn

type OptionFn func(b *Raft)

func Addr

func Addr(addr string) OptionFn

func Config

func Config(raft *raft.Config) OptionFn

func DataDir

func DataDir(dataDir string) OptionFn

func Logger

func Logger(logger *simplelog.Logger) OptionFn

type Raft

type Raft struct {
	// contains filtered or unexported fields
}

Raft manages consensus on Jocko cluster using Hashicorp Raft

func New

func New(opts ...OptionFn) (*Raft, error)

New Raft object

func (*Raft) AddPeer

func (b *Raft) AddPeer(addr string) error

AddPeer of given address to raft

func (*Raft) Addr

func (b *Raft) Addr() string

Addr of raft node

func (*Raft) Apply

func (b *Raft) Apply(cmd jocko.RaftCommand) error

Apply command to all raft nodes

func (*Raft) Bootstrap

func (b *Raft) Bootstrap(peers []*jocko.ClusterMember, commandCh chan<- jocko.RaftCommand, leaderCh chan<- bool) (err error)

Bootstrap the Raft agent using fsm and connect to peers Updates to leadership are returned on leaderCh channel Commands received by raft are returned on commandCh channel

func (*Raft) IsLeader

func (b *Raft) IsLeader() bool

IsLeader checks if this broker is the cluster controller

func (*Raft) LeaderID

func (b *Raft) LeaderID() string

LeaderID is ID of the controller node

func (*Raft) RemovePeer

func (b *Raft) RemovePeer(addr string) error

RemovePeer of given address from raft

func (*Raft) Shutdown

func (b *Raft) Shutdown() error

Shutdown raft agent

func (*Raft) WaitForBarrier

func (b *Raft) WaitForBarrier() error

WaitForBarrier to let fsm finish

Jump to

Keyboard shortcuts

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