raftrpc

package
v0.0.0-...-c54ec7c Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendRPCRequest

type AppendRPCRequest struct {
	// leaderId
	LeaderNode *core.ServerInfo

	// log entries to store (empty for heartbeat; may send more than one for efficiency)
	LogEntries []*core.LogEntry

	// leader’s term
	Term int

	// term of prevLogIndex entry
	PrevLogTerm int

	// index of log entry immediately preceding new ones
	PrevLogIndex int

	// leader’s commitIndex
	CommitIndex int
}

type AppendRPCResponse

type AppendRPCResponse struct {

	// currentTerm, for leader to update itself
	Term int

	// true if follower contained entry matching prevLogIndex and prevLogTerm
	Success bool
}

type ClientPool

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

func NewClientPool

func NewClientPool() *ClientPool

func (*ClientPool) Get

func (c *ClientPool) Get(serverAddr *net.TCPAddr) (*rpc.Client, error)

type ClientResponse

type ClientResponse struct {
	Errcode    int
	Errmsg     string
	ServerAddr *net.TCPAddr
	Data       interface{}
}

type RaftApi

type RaftApi interface {
	Get(cmd *entity.Command, resp *ClientResponse) error
	Set(cmd *entity.Command, resp *ClientResponse) error
	OnReceiveAppendRPC(req *AppendRPCRequest, resp *AppendRPCResponse) error
	OnReceiveRequestVoteRPC(req *RequestVoteRequest, resp *RequestVoteResponse) error
}

type RaftService

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

func NewRaftService

func NewRaftService(server RaftApi) *RaftService

func (*RaftService) Get

func (rs *RaftService) Get(cmd *entity.Command, resp *ClientResponse) error

func (*RaftService) OnReceiveAppendRPC

func (rs *RaftService) OnReceiveAppendRPC(req *AppendRPCRequest, resp *AppendRPCResponse) error

func (*RaftService) OnReceiveRequestVoteRPC

func (rs *RaftService) OnReceiveRequestVoteRPC(req *RequestVoteRequest, resp *RequestVoteResponse) error

func (*RaftService) Set

func (rs *RaftService) Set(cmd *entity.Command, resp *ClientResponse) error

type RequestVoteRequest

type RequestVoteRequest struct {
	// term of candidate’s last log entry
	LastLogTerm int

	// index of candidate’s last log entry
	LastLogIndex int

	// candidate’s term
	NextTerm int

	// candidate requesting vote
	Candidate *core.ServerInfo
}

type RequestVoteResponse

type RequestVoteResponse struct {
	// currentTerm, for candidate to update itself
	Term int

	// true means candidate received vote
	Accept bool
}

Jump to

Keyboard shortcuts

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