raft

package
v0.0.0-...-c817ce6 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Leader    = "leader"
	Candidate = "candidate"
	Follower  = "follower"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NoteVotedArgs

type NoteVotedArgs struct {
	Role    string
	Address string
	Term    int
}

type Proc

type Proc interface {
	Do(string, interface{}, interface{}) error
	WriteSnapshot(string, int64) error
	ReadSnapshot(string, *int64) error
	WriteDataIni(*os.File, int64) error
}

type Raft

type Raft struct {
	HttpPort string

	EntryMu sync.Mutex

	Address string
	Leader  string

	Cluster []*rpclib.Node

	Entries *common.Entries

	EntryFile *os.File
	EntryPath string
	OpLogFile *os.File
	OpLogPath string

	Server *rpc.Server
	// contains filtered or unexported fields
}

func New

func New(filename string, p Proc) *Raft

func (*Raft) AppendEntries

func (r *Raft) AppendEntries(et common.Entry, reply *bool) error

func (*Raft) Do

func (r *Raft) Do(et common.Entry, reply *common.RetValue) error

func (*Raft) Exec

func (r *Raft) Exec(et common.Entry, reply *common.RetValue) error

func (*Raft) HeartBeat

func (r *Raft) HeartBeat(args NoteVotedArgs, reply *common.HeartBeatRetVal) error

func (*Raft) ImAlived

func (r *Raft) ImAlived()

func (*Raft) InstallSnapShot

func (r *Raft) InstallSnapShot(args []common.Entry, reply *bool) error

func (*Raft) NoteVoted

func (r *Raft) NoteVoted(args RequestVoteArgs, reply *bool) error

func (*Raft) RefactorCluster

func (r *Raft) RefactorCluster()

func (*Raft) RequestVoted

func (r *Raft) RequestVoted(args RequestVoteArgs, reply *bool) error

func (*Raft) Restore

func (r *Raft) Restore()

func (*Raft) Run

func (r *Raft) Run()

func (*Raft) SendNotice

func (r *Raft) SendNotice() error

func (*Raft) SendVoted

func (r *Raft) SendVoted() int

func (*Raft) SyncEntries

func (r *Raft) SyncEntries(nextIndex int64, reply *[]common.Entry) error

func (*Raft) Topology

func (r *Raft) Topology(_ common.Entry, reply *common.RetValue) error

func (*Raft) Wait

func (r *Raft) Wait()

func (*Raft) WriteEntries

func (r *Raft) WriteEntries(et *common.Entry) error

type RequestVoteArgs

type RequestVoteArgs struct {
	Term    int
	Index   int64
	Address string
}

Jump to

Keyboard shortcuts

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