proto

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfAddNode    ConfChangeType = 0
	ConfRemoveNode ConfChangeType = 1
	ConfUpdateNode ConfChangeType = 2

	EntryNormal     EntryType = 0
	EntryConfChange EntryType = 1

	PeerNormal  PeerType = 0
	PeerArbiter PeerType = 1
)

Variables

This section is empty.

Functions

func EncodeHBConext

func EncodeHBConext(ctx HeartbeatContext) (buf []byte)

func ReturnMessage

func ReturnMessage(msg *Message)

Types

type ConfChange

type ConfChange struct {
	Type    ConfChangeType
	Peer    Peer
	Context []byte
}

func (*ConfChange) Decode

func (c *ConfChange) Decode(datas []byte)

func (*ConfChange) Encode

func (c *ConfChange) Encode() []byte

ConfChange codec

func (*ConfChange) String

func (cc *ConfChange) String() string

type ConfChangeType

type ConfChangeType byte

func (ConfChangeType) String

func (t ConfChangeType) String() string

type Entry

type Entry struct {
	Type  EntryType
	Term  uint64
	Index uint64
	Data  []byte
}

Entry is the repl log entry.

func (*Entry) Decode

func (e *Entry) Decode(datas []byte)

func (*Entry) Encode

func (e *Entry) Encode(w io.Writer) error

func (*Entry) Size

func (e *Entry) Size() uint64

Entry codec

type EntryType

type EntryType byte

func (EntryType) String

func (t EntryType) String() string

type HardState

type HardState struct {
	Term   uint64
	Commit uint64
	Vote   uint64
}

HardState is the repl state,must persist to the storage.

func (*HardState) Decode

func (c *HardState) Decode(datas []byte)

func (*HardState) Encode

func (c *HardState) Encode(datas []byte)

HardState codec

func (*HardState) IsEmpty

func (s *HardState) IsEmpty() bool

func (*HardState) Size

func (c *HardState) Size() uint64

type HeartbeatContext

type HeartbeatContext []uint64

func DecodeHBContext

func DecodeHBContext(buf []byte) (ctx HeartbeatContext)

type Message

type Message struct {
	Type         MsgType
	ForceVote    bool
	Reject       bool
	RejectIndex  uint64
	ID           uint64
	From         uint64
	To           uint64
	Term         uint64
	LogTerm      uint64
	Index        uint64
	Commit       uint64
	SnapshotMeta SnapshotMeta
	Entries      []*Entry
	Context      []byte
	Snapshot     Snapshot // No need for codec
}

Message is the transport message.

func GetMessage

func GetMessage() *Message

func (*Message) Decode

func (m *Message) Decode(r *util.BufferReader) error

func (*Message) Encode

func (m *Message) Encode(w io.Writer) error

func (*Message) IsElectionMsg

func (m *Message) IsElectionMsg() bool

func (*Message) IsHeartbeatMsg

func (m *Message) IsHeartbeatMsg() bool

func (*Message) IsResponseMsg

func (m *Message) IsResponseMsg() bool

func (*Message) Size

func (m *Message) Size() uint64

Message codec

type MsgType

type MsgType byte
const (
	ReqMsgAppend MsgType = iota
	ReqMsgVote
	ReqMsgHeartBeat
	ReqMsgSnapShot
	ReqMsgElectAck
	RespMsgAppend
	RespMsgVote
	RespMsgHeartBeat
	RespMsgSnapShot
	RespMsgElectAck
	LocalMsgHup
	LocalMsgProp
	LeaseMsgOffline
	LeaseMsgTimeout
)

func (MsgType) String

func (t MsgType) String() string

type Peer

type Peer struct {
	Type     PeerType
	Priority uint16
	ID       uint64
}

func (*Peer) Decode

func (p *Peer) Decode(datas []byte)

func (*Peer) Encode

func (p *Peer) Encode(datas []byte)

Peer codec

func (Peer) String

func (p Peer) String() string

type PeerType

type PeerType byte

func (PeerType) String

func (t PeerType) String() string

type SnapIterator

type SnapIterator interface {
	// if error=io.EOF represent snapshot terminated.
	Next() ([]byte, error)
}

type Snapshot

type Snapshot interface {
	SnapIterator
	ApplyIndex() uint64
	Close()
}

The Snapshot interface is supplied by the application to access the snapshot data of application.

type SnapshotMeta

type SnapshotMeta struct {
	Index uint64
	Term  uint64
	Peers []Peer
}

func (*SnapshotMeta) Decode

func (m *SnapshotMeta) Decode(datas []byte)

func (*SnapshotMeta) Encode

func (m *SnapshotMeta) Encode(w io.Writer) error

func (*SnapshotMeta) Size

func (m *SnapshotMeta) Size() uint64

SnapshotMeta codec

Jump to

Keyboard shortcuts

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