Documentation ¶
Overview ¶
Package raftpb is a generated protocol buffer package.
It is generated from these files:
raft.proto
It has these top-level messages:
Entry SnapshotMetadata Snapshot Message HardState ConfState ConfChange ConfChangeSingle ConfChangeV2
Index ¶
- Variables
- func ConfChangesToString(ccs []ConfChangeSingle) string
- type ConfChange
- func (c ConfChange) AsV1() (ConfChange, bool)
- func (c ConfChange) AsV2() ConfChangeV2
- func (*ConfChange) Descriptor() ([]byte, []int)
- func (m *ConfChange) Marshal() (dAtA []byte, err error)
- func (m *ConfChange) MarshalTo(dAtA []byte) (int, error)
- func (*ConfChange) ProtoMessage()
- func (m *ConfChange) Reset()
- func (m *ConfChange) Size() (n int)
- func (m *ConfChange) String() string
- func (m *ConfChange) Unmarshal(dAtA []byte) error
- type ConfChangeI
- type ConfChangeSingle
- func (*ConfChangeSingle) Descriptor() ([]byte, []int)
- func (m *ConfChangeSingle) Marshal() (dAtA []byte, err error)
- func (m *ConfChangeSingle) MarshalTo(dAtA []byte) (int, error)
- func (*ConfChangeSingle) ProtoMessage()
- func (m *ConfChangeSingle) Reset()
- func (m *ConfChangeSingle) Size() (n int)
- func (m *ConfChangeSingle) String() string
- func (m *ConfChangeSingle) Unmarshal(dAtA []byte) error
- type ConfChangeTransition
- type ConfChangeType
- type ConfChangeV2
- func (c ConfChangeV2) AsV1() (ConfChange, bool)
- func (c ConfChangeV2) AsV2() ConfChangeV2
- func (*ConfChangeV2) Descriptor() ([]byte, []int)
- func (c *ConfChangeV2) EnterJoint() (autoLeave bool, ok bool)
- func (c *ConfChangeV2) LeaveJoint() bool
- func (m *ConfChangeV2) Marshal() (dAtA []byte, err error)
- func (m *ConfChangeV2) MarshalTo(dAtA []byte) (int, error)
- func (*ConfChangeV2) ProtoMessage()
- func (m *ConfChangeV2) Reset()
- func (m *ConfChangeV2) Size() (n int)
- func (m *ConfChangeV2) String() string
- func (m *ConfChangeV2) Unmarshal(dAtA []byte) error
- type ConfState
- func (*ConfState) Descriptor() ([]byte, []int)
- func (cs ConfState) Equivalent(cs2 ConfState) error
- func (m *ConfState) Marshal() (dAtA []byte, err error)
- func (m *ConfState) MarshalTo(dAtA []byte) (int, error)
- func (*ConfState) ProtoMessage()
- func (m *ConfState) Reset()
- func (m *ConfState) Size() (n int)
- func (m *ConfState) String() string
- func (m *ConfState) Unmarshal(dAtA []byte) error
- type Entry
- func (*Entry) Descriptor() ([]byte, []int)
- func (m *Entry) Marshal() (dAtA []byte, err error)
- func (m *Entry) MarshalTo(dAtA []byte) (int, error)
- func (*Entry) ProtoMessage()
- func (m *Entry) Reset()
- func (m *Entry) Size() (n int)
- func (m *Entry) String() string
- func (m *Entry) Unmarshal(dAtA []byte) error
- type EntryType
- type HardState
- func (*HardState) Descriptor() ([]byte, []int)
- func (m *HardState) Marshal() (dAtA []byte, err error)
- func (m *HardState) MarshalTo(dAtA []byte) (int, error)
- func (*HardState) ProtoMessage()
- func (m *HardState) Reset()
- func (m *HardState) Size() (n int)
- func (m *HardState) String() string
- func (m *HardState) Unmarshal(dAtA []byte) error
- type Message
- func (*Message) Descriptor() ([]byte, []int)
- func (m *Message) Marshal() (dAtA []byte, err error)
- func (m *Message) MarshalTo(dAtA []byte) (int, error)
- func (*Message) ProtoMessage()
- func (m *Message) Reset()
- func (m *Message) Size() (n int)
- func (m *Message) String() string
- func (m *Message) Unmarshal(dAtA []byte) error
- type MessageType
- type Snapshot
- func (*Snapshot) Descriptor() ([]byte, []int)
- func (m *Snapshot) Marshal() (dAtA []byte, err error)
- func (m *Snapshot) MarshalTo(dAtA []byte) (int, error)
- func (*Snapshot) ProtoMessage()
- func (m *Snapshot) Reset()
- func (m *Snapshot) Size() (n int)
- func (m *Snapshot) String() string
- func (m *Snapshot) Unmarshal(dAtA []byte) error
- type SnapshotMetadata
- func (*SnapshotMetadata) Descriptor() ([]byte, []int)
- func (m *SnapshotMetadata) Marshal() (dAtA []byte, err error)
- func (m *SnapshotMetadata) MarshalTo(dAtA []byte) (int, error)
- func (*SnapshotMetadata) ProtoMessage()
- func (m *SnapshotMetadata) Reset()
- func (m *SnapshotMetadata) Size() (n int)
- func (m *SnapshotMetadata) String() string
- func (m *SnapshotMetadata) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthRaft = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow") )
var ConfChangeTransition_name = map[int32]string{
0: "ConfChangeTransitionAuto",
1: "ConfChangeTransitionJointImplicit",
2: "ConfChangeTransitionJointExplicit",
}
var ConfChangeTransition_value = map[string]int32{
"ConfChangeTransitionAuto": 0,
"ConfChangeTransitionJointImplicit": 1,
"ConfChangeTransitionJointExplicit": 2,
}
var ConfChangeType_name = map[int32]string{
0: "ConfChangeAddNode",
1: "ConfChangeRemoveNode",
2: "ConfChangeUpdateNode",
3: "ConfChangeAddLearnerNode",
}
var ConfChangeType_value = map[string]int32{
"ConfChangeAddNode": 0,
"ConfChangeRemoveNode": 1,
"ConfChangeUpdateNode": 2,
"ConfChangeAddLearnerNode": 3,
}
var EntryType_name = map[int32]string{
0: "EntryNormal",
1: "EntryConfChange",
2: "EntryConfChangeV2",
}
var EntryType_value = map[string]int32{
"EntryNormal": 0,
"EntryConfChange": 1,
"EntryConfChangeV2": 2,
}
var MessageType_name = map[int32]string{
0: "MsgHup",
1: "MsgBeat",
2: "MsgProp",
3: "MsgApp",
4: "MsgAppResp",
5: "MsgVote",
6: "MsgVoteResp",
7: "MsgSnap",
8: "MsgHeartbeat",
9: "MsgHeartbeatResp",
10: "MsgUnreachable",
11: "MsgSnapStatus",
12: "MsgCheckQuorum",
13: "MsgTransferLeader",
14: "MsgTimeoutNow",
15: "MsgReadIndex",
16: "MsgReadIndexResp",
17: "MsgPreVote",
18: "MsgPreVoteResp",
}
var MessageType_value = map[string]int32{
"MsgHup": 0,
"MsgBeat": 1,
"MsgProp": 2,
"MsgApp": 3,
"MsgAppResp": 4,
"MsgVote": 5,
"MsgVoteResp": 6,
"MsgSnap": 7,
"MsgHeartbeat": 8,
"MsgHeartbeatResp": 9,
"MsgUnreachable": 10,
"MsgSnapStatus": 11,
"MsgCheckQuorum": 12,
"MsgTransferLeader": 13,
"MsgTimeoutNow": 14,
"MsgReadIndex": 15,
"MsgReadIndexResp": 16,
"MsgPreVote": 17,
"MsgPreVoteResp": 18,
}
Functions ¶
func ConfChangesToString ¶
func ConfChangesToString(ccs []ConfChangeSingle) string
ConfChangesToString is the inverse to ConfChangesFromString.
Types ¶
type ConfChange ¶
type ConfChange struct { Type ConfChangeType `protobuf:"varint,2,opt,name=type,enum=raftpb.ConfChangeType" json:"type"` NodeID uint64 `protobuf:"varint,3,opt,name=node_id,json=nodeId" json:"node_id"` Context []byte `protobuf:"bytes,4,opt,name=context" json:"context,omitempty"` // NB: this is used only by etcd to thread through a unique identifier. // Ideally it should really use the Context instead. No counterpart to // this field exists in ConfChangeV2. ID uint64 `protobuf:"varint,1,opt,name=id" json:"id"` XXX_unrecognized []byte `json:"-"` }
func (ConfChange) AsV1 ¶
func (c ConfChange) AsV1() (ConfChange, bool)
AsV1 returns the ConfChange and true.
func (ConfChange) AsV2 ¶
func (c ConfChange) AsV2() ConfChangeV2
AsV2 returns a V2 configuration change carrying out the same operation.
func (*ConfChange) Descriptor ¶
func (*ConfChange) Descriptor() ([]byte, []int)
func (*ConfChange) Marshal ¶
func (m *ConfChange) Marshal() (dAtA []byte, err error)
func (*ConfChange) MarshalTo ¶
func (m *ConfChange) MarshalTo(dAtA []byte) (int, error)
func (*ConfChange) ProtoMessage ¶
func (*ConfChange) ProtoMessage()
func (*ConfChange) Reset ¶
func (m *ConfChange) Reset()
func (*ConfChange) Size ¶
func (m *ConfChange) Size() (n int)
func (*ConfChange) String ¶
func (m *ConfChange) String() string
func (*ConfChange) Unmarshal ¶
func (m *ConfChange) Unmarshal(dAtA []byte) error
type ConfChangeI ¶
type ConfChangeI interface { AsV2() ConfChangeV2 AsV1() (ConfChange, bool) }
ConfChangeI abstracts over ConfChangeV2 and (legacy) ConfChange to allow treating them in a unified manner.
type ConfChangeSingle ¶
type ConfChangeSingle struct { Type ConfChangeType `protobuf:"varint,1,opt,name=type,enum=raftpb.ConfChangeType" json:"type"` NodeID uint64 `protobuf:"varint,2,opt,name=node_id,json=nodeId" json:"node_id"` XXX_unrecognized []byte `json:"-"` }
ConfChangeSingle is an individual configuration change operation. Multiple such operations can be carried out atomically via a ConfChangeV2.
func ConfChangesFromString ¶
func ConfChangesFromString(s string) ([]ConfChangeSingle, error)
ConfChangesFromString parses a Space-delimited sequence of operations into a slice of ConfChangeSingle. The supported operations are: - vn: make n a voter, - ln: make n a learner, - rn: remove n, and - un: update n.
func (*ConfChangeSingle) Descriptor ¶
func (*ConfChangeSingle) Descriptor() ([]byte, []int)
func (*ConfChangeSingle) Marshal ¶
func (m *ConfChangeSingle) Marshal() (dAtA []byte, err error)
func (*ConfChangeSingle) MarshalTo ¶
func (m *ConfChangeSingle) MarshalTo(dAtA []byte) (int, error)
func (*ConfChangeSingle) ProtoMessage ¶
func (*ConfChangeSingle) ProtoMessage()
func (*ConfChangeSingle) Reset ¶
func (m *ConfChangeSingle) Reset()
func (*ConfChangeSingle) Size ¶
func (m *ConfChangeSingle) Size() (n int)
func (*ConfChangeSingle) String ¶
func (m *ConfChangeSingle) String() string
func (*ConfChangeSingle) Unmarshal ¶
func (m *ConfChangeSingle) Unmarshal(dAtA []byte) error
type ConfChangeTransition ¶
type ConfChangeTransition int32
ConfChangeTransition specifies the behavior of a configuration change with respect to joint consensus.
const ( // Automatically use the simple protocol if possible, otherwise fall back // to ConfChangeJointImplicit. Most applications will want to use this. ConfChangeTransitionAuto ConfChangeTransition = 0 // Use joint consensus unconditionally, and transition out of them // automatically (by proposing a zero configuration change). // // This option is suitable for applications that want to minimize the time // spent in the joint configuration and do not store the joint configuration // in the state machine (outside of InitialState). ConfChangeTransitionJointImplicit ConfChangeTransition = 1 // Use joint consensus and remain in the joint configuration until the // application proposes a no-op configuration change. This is suitable for // applications that want to explicitly control the transitions, for example // to use a custom payload (via the Context field). ConfChangeTransitionJointExplicit ConfChangeTransition = 2 )
func (ConfChangeTransition) Enum ¶
func (x ConfChangeTransition) Enum() *ConfChangeTransition
func (ConfChangeTransition) EnumDescriptor ¶
func (ConfChangeTransition) EnumDescriptor() ([]byte, []int)
func (ConfChangeTransition) String ¶
func (x ConfChangeTransition) String() string
func (*ConfChangeTransition) UnmarshalJSON ¶
func (x *ConfChangeTransition) UnmarshalJSON(data []byte) error
type ConfChangeType ¶
type ConfChangeType int32
const ( ConfChangeAddNode ConfChangeType = 0 ConfChangeRemoveNode ConfChangeType = 1 ConfChangeUpdateNode ConfChangeType = 2 ConfChangeAddLearnerNode ConfChangeType = 3 )
func (ConfChangeType) Enum ¶
func (x ConfChangeType) Enum() *ConfChangeType
func (ConfChangeType) EnumDescriptor ¶
func (ConfChangeType) EnumDescriptor() ([]byte, []int)
func (ConfChangeType) String ¶
func (x ConfChangeType) String() string
func (*ConfChangeType) UnmarshalJSON ¶
func (x *ConfChangeType) UnmarshalJSON(data []byte) error
type ConfChangeV2 ¶
type ConfChangeV2 struct { Transition ConfChangeTransition `protobuf:"varint,1,opt,name=transition,enum=raftpb.ConfChangeTransition" json:"transition"` Changes []ConfChangeSingle `protobuf:"bytes,2,rep,name=changes" json:"changes"` Context []byte `protobuf:"bytes,3,opt,name=context" json:"context,omitempty"` XXX_unrecognized []byte `json:"-"` }
ConfChangeV2 messages initiate configuration changes. They support both the simple "one at a time" membership change protocol and full Joint Consensus allowing for arbitrary changes in membership.
The supplied context is treated as an opaque payload and can be used to attach an action on the state machine to the application of the config change proposal. Note that contrary to Joint Consensus as outlined in the Raft paper1, configuration changes become active when they are *applied* to the state machine (not when they are appended to the log).
The simple protocol can be used whenever only a single change is made.
Non-simple changes require the use of Joint Consensus, for which two configuration changes are run. The first configuration change specifies the desired changes and transitions the Raft group into the joint configuration, in which quorum requires a majority of both the pre-changes and post-changes configuration. Joint Consensus avoids entering fragile intermediate configurations that could compromise survivability. For example, without the use of Joint Consensus and running across three availability zones with a replication factor of three, it is not possible to replace a voter without entering an intermediate configuration that does not survive the outage of one availability zone.
The provided ConfChangeTransition specifies how (and whether) Joint Consensus is used, and assigns the task of leaving the joint configuration either to Raft or the application. Leaving the joint configuration is accomplished by proposing a ConfChangeV2 with only and optionally the Context field populated.
For details on Raft membership changes, see:
func (ConfChangeV2) AsV1 ¶
func (c ConfChangeV2) AsV1() (ConfChange, bool)
AsV1 returns ConfChange{} and false.
func (*ConfChangeV2) Descriptor ¶
func (*ConfChangeV2) Descriptor() ([]byte, []int)
func (*ConfChangeV2) EnterJoint ¶
func (c *ConfChangeV2) EnterJoint() (autoLeave bool, ok bool)
EnterJoint returns two bools. The second bool is true if and only if this config change will use Joint Consensus, which is the case if it contains more than one change or if the use of Joint Consensus was requested explicitly. The first bool can only be true if second one is, and indicates whether the Joint State will be left automatically.
func (*ConfChangeV2) LeaveJoint ¶
func (c *ConfChangeV2) LeaveJoint() bool
LeaveJoint is true if the configuration change leaves a joint configuration. This is the case if the ConfChangeV2 is zero, with the possible exception of the Context field.
func (*ConfChangeV2) Marshal ¶
func (m *ConfChangeV2) Marshal() (dAtA []byte, err error)
func (*ConfChangeV2) MarshalTo ¶
func (m *ConfChangeV2) MarshalTo(dAtA []byte) (int, error)
func (*ConfChangeV2) ProtoMessage ¶
func (*ConfChangeV2) ProtoMessage()
func (*ConfChangeV2) Reset ¶
func (m *ConfChangeV2) Reset()
func (*ConfChangeV2) Size ¶
func (m *ConfChangeV2) Size() (n int)
func (*ConfChangeV2) String ¶
func (m *ConfChangeV2) String() string
func (*ConfChangeV2) Unmarshal ¶
func (m *ConfChangeV2) Unmarshal(dAtA []byte) error
type ConfState ¶
type ConfState struct { // The voters in the incoming config. (If the configuration is not joint, // then the outgoing config is empty). Voters []uint64 `protobuf:"varint,1,rep,name=voters" json:"voters,omitempty"` // The learners in the incoming config. Learners []uint64 `protobuf:"varint,2,rep,name=learners" json:"learners,omitempty"` // The voters in the outgoing config. VotersOutgoing []uint64 `protobuf:"varint,3,rep,name=voters_outgoing,json=votersOutgoing" json:"voters_outgoing,omitempty"` // The nodes that will become learners when the outgoing config is removed. // These nodes are necessarily currently in nodes_joint (or they would have // been added to the incoming config right away). LearnersNext []uint64 `protobuf:"varint,4,rep,name=learners_next,json=learnersNext" json:"learners_next,omitempty"` // If set, the config is joint and Raft will automatically transition into // the final config (i.e. remove the outgoing config) when this is safe. AutoLeave bool `protobuf:"varint,5,opt,name=auto_leave,json=autoLeave" json:"auto_leave"` XXX_unrecognized []byte `json:"-"` }
func (ConfState) Equivalent ¶
Equivalent returns a nil error if the inputs describe the same configuration. On mismatch, returns a descriptive error showing the differences.
type Entry ¶
type Entry struct { Term uint64 `protobuf:"varint,2,opt,name=Term" json:"Term"` Index uint64 `protobuf:"varint,3,opt,name=Index" json:"Index"` Type EntryType `protobuf:"varint,1,opt,name=Type,enum=raftpb.EntryType" json:"Type"` Data []byte `protobuf:"bytes,4,opt,name=Data" json:"Data,omitempty"` XXX_unrecognized []byte `json:"-"` }
type EntryType ¶
type EntryType int32
func MarshalConfChange ¶
func MarshalConfChange(c ConfChangeI) (EntryType, []byte, error)
MarshalConfChange calls Marshal on the underlying ConfChange or ConfChangeV2 and returns the result along with the corresponding EntryType.
type HardState ¶
type Message ¶
type Message struct { Type MessageType `protobuf:"varint,1,opt,name=type,enum=raftpb.MessageType" json:"type"` To uint64 `protobuf:"varint,2,opt,name=to" json:"to"` From uint64 `protobuf:"varint,3,opt,name=from" json:"from"` Term uint64 `protobuf:"varint,4,opt,name=term" json:"term"` LogTerm uint64 `protobuf:"varint,5,opt,name=logTerm" json:"logTerm"` Index uint64 `protobuf:"varint,6,opt,name=index" json:"index"` Entries []Entry `protobuf:"bytes,7,rep,name=entries" json:"entries"` Commit uint64 `protobuf:"varint,8,opt,name=commit" json:"commit"` Snapshot Snapshot `protobuf:"bytes,9,opt,name=snapshot" json:"snapshot"` Reject bool `protobuf:"varint,10,opt,name=reject" json:"reject"` RejectHint uint64 `protobuf:"varint,11,opt,name=rejectHint" json:"rejectHint"` Context []byte `protobuf:"bytes,12,opt,name=context" json:"context,omitempty"` XXX_unrecognized []byte `json:"-"` }
type MessageType ¶
type MessageType int32
const ( MsgHup MessageType = 0 MsgBeat MessageType = 1 MsgProp MessageType = 2 MsgApp MessageType = 3 MsgAppResp MessageType = 4 MsgVote MessageType = 5 MsgVoteResp MessageType = 6 MsgSnap MessageType = 7 MsgHeartbeat MessageType = 8 MsgHeartbeatResp MessageType = 9 MsgUnreachable MessageType = 10 MsgSnapStatus MessageType = 11 MsgCheckQuorum MessageType = 12 MsgTransferLeader MessageType = 13 MsgTimeoutNow MessageType = 14 MsgReadIndex MessageType = 15 MsgReadIndexResp MessageType = 16 MsgPreVote MessageType = 17 MsgPreVoteResp MessageType = 18 )
func (MessageType) Enum ¶
func (x MessageType) Enum() *MessageType
func (MessageType) EnumDescriptor ¶
func (MessageType) EnumDescriptor() ([]byte, []int)
func (MessageType) String ¶
func (x MessageType) String() string
func (*MessageType) UnmarshalJSON ¶
func (x *MessageType) UnmarshalJSON(data []byte) error
type Snapshot ¶
type Snapshot struct { Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` Metadata SnapshotMetadata `protobuf:"bytes,2,opt,name=metadata" json:"metadata"` XXX_unrecognized []byte `json:"-"` }
type SnapshotMetadata ¶
type SnapshotMetadata struct { ConfState ConfState `protobuf:"bytes,1,opt,name=conf_state,json=confState" json:"conf_state"` Index uint64 `protobuf:"varint,2,opt,name=index" json:"index"` Term uint64 `protobuf:"varint,3,opt,name=term" json:"term"` XXX_unrecognized []byte `json:"-"` }
func (*SnapshotMetadata) Descriptor ¶
func (*SnapshotMetadata) Descriptor() ([]byte, []int)
func (*SnapshotMetadata) Marshal ¶
func (m *SnapshotMetadata) Marshal() (dAtA []byte, err error)
func (*SnapshotMetadata) MarshalTo ¶
func (m *SnapshotMetadata) MarshalTo(dAtA []byte) (int, error)
func (*SnapshotMetadata) ProtoMessage ¶
func (*SnapshotMetadata) ProtoMessage()
func (*SnapshotMetadata) Reset ¶
func (m *SnapshotMetadata) Reset()
func (*SnapshotMetadata) Size ¶
func (m *SnapshotMetadata) Size() (n int)
func (*SnapshotMetadata) String ¶
func (m *SnapshotMetadata) String() string
func (*SnapshotMetadata) Unmarshal ¶
func (m *SnapshotMetadata) Unmarshal(dAtA []byte) error