types

package
v0.0.0-...-2ad55f5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendEntriesRPC

type AppendEntriesRPC struct {
	Term         uint64 `json:"term"`           // the leader's term
	LeaderID     string `json:"leader_id"`      // the leader's ID (this allows followers to redirect clients)
	PrevLogIndex uint64 `json:"prev_log_index"` // the index of the log entry immediately preceding new logs
	PrevLogTerm  uint64 `json:"prev_log_term"`  // the term of PrevLogIndex
	Logs         []Log  `json:"logs"`           // the log entries to store
	CommitIndex  uint64 `json:"commit_index"`   // the leader's commit index
}

AppendEntriesRPC defines an RPC method used to handle a leader attempting to replicate log entries. It is also used as a heartbeat mechanism.

type JSONLogDecoder

type JSONLogDecoder struct{}

JSONLogDecoder provides log JSON deserialization. It implements the LogDecoder interface.

func (JSONLogDecoder) Decode

func (d JSONLogDecoder) Decode(data []byte, log *Log) error

Decode returns a JSON decoded log. It returns an error upon failure.

type JSONLogEncoder

type JSONLogEncoder struct{}

JSONLogEncoder provides log JSON serialization. It implements the LogEncoder interface.

func (JSONLogEncoder) Encode

func (e JSONLogEncoder) Encode(log Log) ([]byte, error)

Encode returns a JSON encoded log. It returns an error upon failure.

type Log

type Log struct {
	Index   uint64 `json:"index"`
	Term    uint64 `json:"term"`
	Command []byte `json:"command"`
}

Log represents a command to execute in a state machine. Each log contains a monotonically increasing index and a term for when the log entry was received by a leader.

Contract: If two logs contain a log entry with the same index and term, then the logs are identical in all entries up through the given index.

func NewLog

func NewLog(index, term uint64, command []byte) Log

type LogDecoder

type LogDecoder interface {
	Decode([]byte, *Log) error
}

LogDecoder describes an interface that is able to decode an arbitrary series of bytes into a log.

type LogEncoder

type LogEncoder interface {
	Encode(Log) ([]byte, error)
}

LogEncoder describes an interface that is able to encode a log into an arbitrary series of bytes.

type RequestVoteRPC

type RequestVoteRPC struct {
	Term         uint64 `json:"term"`           // the candidate's term
	CandidateID  string `json:"candidate_id"`   // the candidate requesting a vote
	LastLogIndex uint64 `json:"last_log_index"` // the index of the candidate's last log entry
	LastLogTerm  uint64 `json:"last_log_term"`  // the term of the candidate's last log entry
}

RequestVoteRPC defines an RPC method used to handle requesting and gathering Raft votes.

Jump to

Keyboard shortcuts

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