comm

package
v0.0.0-...-f5efa4d Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

This package is in charge of sending rpc request and handling the received request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppEntryArgs

type AppEntryArgs struct {
	Term         int
	LeaderId     int
	PrevLogIndex int
	PrevLogTerm  int
	Entries      []Entry
	LeaderCommit int
}

type AppEntryChan

type AppEntryChan struct {
	Args   chan *AppEntryArgs
	Result chan *AppEntryResult
}

func NewAppEntryChan

func NewAppEntryChan() AppEntryChan

type AppEntryResult

type AppEntryResult struct {
	Term    int
	Success bool
}

type Command

type Command interface {
	Serialise() string
	UnSerialise(cmd string)
}

type DataChan

type DataChan struct {
	Vc VoteChan
	Ac AppEntryChan
}

func NewDataChan

func NewDataChan() DataChan

func (DataChan) Close

func (dc DataChan) Close()

type DataService

type DataService interface {
	GetDataChan() <-chan DataChan
}

type Entry

type Entry struct {
	Term     int
	LogIndex int
	Cmd      string
}

func (Entry) Serialise

func (e Entry) Serialise() (string, error)

func (*Entry) UnSerialise

func (e *Entry) UnSerialise(data string) error

type Listener

type Listener struct {
	Addr string
	Serv *Service
}

func NewListener

func NewListener(addr string) Listener

func (Listener) GetDataChan

func (ls Listener) GetDataChan() <-chan DataChan

func (*Listener) Run

func (ls *Listener) Run()

type Sender

type Sender struct {
	Addr []string
}

func (*Sender) AppEntries

func (s *Sender) AppEntries(addr string, args AppEntryArgs, result *AppEntryResult) error

func (*Sender) RequestVote

func (s *Sender) RequestVote(addr string, args VoteArgs, result *VoteResult) error

type Service

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

func NewService

func NewService(num int) *Service

func (*Service) AppendEntries

func (r *Service) AppendEntries(args *AppEntryArgs, result *AppEntryResult) error

func (Service) GetDataChan

func (s Service) GetDataChan() <-chan DataChan

func (*Service) RequestVote

func (r *Service) RequestVote(args *VoteArgs, result *VoteResult) error

type VoteArgs

type VoteArgs struct {
	Term         int
	CandidateId  int
	LastLogIndex int
	LastLogTerm  int
}

type VoteChan

type VoteChan struct {
	Args   chan *VoteArgs
	Result chan *VoteResult
}

func NewVoteChan

func NewVoteChan() VoteChan

type VoteResult

type VoteResult struct {
	Term        int
	VoteGranted bool
}

Jump to

Keyboard shortcuts

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