models

package
v0.0.0-...-989240d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendEntryPayload

type AppendEntryPayload struct {
	Term         uint64
	LeaderId     string
	PrevLogIndex uint64
	PrevLogTerm  uint64
	Entries      []byte
	LeaderCommit uint64
}

func (*AppendEntryPayload) ToRequest

func (aep *AppendEntryPayload) ToRequest() (Request, error)

type AppendEntryResponse

type AppendEntryResponse struct {
	Term    uint64
	Success bool
}

func (*AppendEntryResponse) FromPayload

func (aer *AppendEntryResponse) FromPayload(payload []byte) error

type ClientCommandPayload

type ClientCommandPayload struct {
	ClientCommand []byte
}

func (*ClientCommandPayload) ToRequest

func (ccp *ClientCommandPayload) ToRequest() (Request, error)

type Request

type Request struct {
	RequestType RequestType
	Payload     []byte
}

type RequestConverter

type RequestConverter interface {
	ToRequest() (Request, error)
}

type RequestType

type RequestType int

RequestType defines the kind of request received by the RaftServer, it can be one of 'AppendEntry' 'RequestVote' or 'ClientCommand'

const (
	AppendEntry RequestType = iota
	RequestVote
	ClientCommand
)

func (RequestType) String

func (i RequestType) String() string

type RequestVotePayload

type RequestVotePayload struct {
	Term         uint64
	CandidateId  string
	LastLogIndex uint64
	LastLogTerm  uint64
}

func (*RequestVotePayload) ToRequest

func (rvp *RequestVotePayload) ToRequest() (Request, error)

type RequestVoteResponse

type RequestVoteResponse struct {
	Term        uint64
	VoteGranted bool
}

func (*RequestVoteResponse) FromPayload

func (rvr *RequestVoteResponse) FromPayload(payload []byte) error

type Response

type Response struct {
	Payload []byte
}

Jump to

Keyboard shortcuts

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