naive_raft

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

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

Go to latest
Published: Jan 10, 2018 License: Apache-2.0 Imports: 15 Imported by: 2

README

naive

Naive_Raft

"Too simple! Sometimes naive!"

"Re-election will still have to follow the (Hong Kong) Basic Law! Of course, our decision is very important too."

-- the elder □-□

naive go implementation of raft consensus algorithm raft

LICENSE

Copyright © 2018 by Aljun

Under Apache license : http://www.apache.org/licenses/

Documentation

Index

Constants

View Source
const (
	FOLLOWER = iota
	CANDIDATE
	LEADER
)
View Source
const (
	INTERVAL = 5 //heartbeat INTERVAL
)
View Source
const ZERO_REPLACE_NUM = 10000000

fix golang pointer convert 0 error

Variables

View Source
var (
	StateErr       = errors.New("wrone state")
	NotCandiateErr = errors.New("not candidate")
	NotLeaderErr   = errors.New("not leader")
	SetLogErr      = errors.New("can't set log")
	NoLogErr       = errors.New("node don't have logs")
)

Functions

This section is empty.

Types

type Log

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

type Node

type Node struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

func NewNode

func NewNode(name string, id int, host string, port int, conf string) *Node

func (*Node) AppendEntriesRPC

func (node *Node) AppendEntriesRPC(ctx context.Context, in *pb.AppendEntriesReq) (*pb.AppendEntriesResp, error)

func (*Node) AppendEntry

func (node *Node) AppendEntry() error

func (*Node) Canvass

func (node *Node) Canvass() error

func (*Node) CanvassRPC

func (node *Node) CanvassRPC(ctx context.Context, in *pb.CanvassReq) (*pb.CanvassResp, error)

func (*Node) Run

func (node *Node) Run()

func (*Node) SetLogRPC

func (node *Node) SetLogRPC(ctx context.Context, in *pb.LogReq) (*pb.LogResp, error)

type NodeConf

type NodeConf struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
	Host string `json:"host"`
	Port int    `json:"port"`
}

Directories

Path Synopsis
Package naive_raft is a generated protocol buffer package.
Package naive_raft is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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