proto

package
v0.0.0-...-b25a44a Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 6 Imported by: 64

Documentation

Overview

Copyright 2018 The tiglabs raft Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018 The tiglabs raft Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

func (*Message) ToString

func (m *Message) ToString() (mesg string)

type MsgType

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

func (MsgType) String

func (t MsgType) String() string

type Peer

type Peer struct {
	Type     PeerType
	Priority uint16
	ID       uint64 // NodeID
	PeerID   uint64 // Replica ID, unique over all raft groups and all replicas in the same group
}

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