Documentation
¶
Index ¶
- Constants
- Variables
- func ConfChangesToString(ccs []*ConfChangeSingle) string
- type ConfChange
- func (c *ConfChange) AsV1() (*ConfChange, bool)
- func (c *ConfChange) AsV2() *ConfChangeV2
- func (*ConfChange) Descriptor() ([]byte, []int)deprecated
- func (x *ConfChange) GetContext() []byte
- func (x *ConfChange) GetId() uint64
- func (x *ConfChange) GetNodeId() uint64
- func (x *ConfChange) GetType() ConfChangeType
- func (*ConfChange) ProtoMessage()
- func (x *ConfChange) ProtoReflect() protoreflect.Message
- func (x *ConfChange) Reset()
- func (x *ConfChange) String() string
- type ConfChangeI
- type ConfChangeSingle
- func (*ConfChangeSingle) Descriptor() ([]byte, []int)deprecated
- func (x *ConfChangeSingle) GetNodeId() uint64
- func (x *ConfChangeSingle) GetType() ConfChangeType
- func (*ConfChangeSingle) ProtoMessage()
- func (x *ConfChangeSingle) ProtoReflect() protoreflect.Message
- func (x *ConfChangeSingle) Reset()
- func (x *ConfChangeSingle) String() string
- type ConfChangeTransition
- func (ConfChangeTransition) Descriptor() protoreflect.EnumDescriptor
- func (x ConfChangeTransition) Enum() *ConfChangeTransition
- func (ConfChangeTransition) EnumDescriptor() ([]byte, []int)deprecated
- func (x ConfChangeTransition) Number() protoreflect.EnumNumber
- func (x ConfChangeTransition) String() string
- func (ConfChangeTransition) Type() protoreflect.EnumType
- func (x *ConfChangeTransition) UnmarshalJSON(b []byte) errordeprecated
- type ConfChangeType
- func (ConfChangeType) Descriptor() protoreflect.EnumDescriptor
- func (x ConfChangeType) Enum() *ConfChangeType
- func (ConfChangeType) EnumDescriptor() ([]byte, []int)deprecated
- func (x ConfChangeType) Number() protoreflect.EnumNumber
- func (x ConfChangeType) String() string
- func (ConfChangeType) Type() protoreflect.EnumType
- func (x *ConfChangeType) UnmarshalJSON(b []byte) errordeprecated
- type ConfChangeV2
- func (c *ConfChangeV2) AsV1() (*ConfChange, bool)
- func (c *ConfChangeV2) AsV2() *ConfChangeV2
- func (*ConfChangeV2) Descriptor() ([]byte, []int)deprecated
- func (c *ConfChangeV2) EnterJoint() (autoLeave bool, ok bool)
- func (x *ConfChangeV2) GetChanges() []*ConfChangeSingle
- func (x *ConfChangeV2) GetContext() []byte
- func (x *ConfChangeV2) GetTransition() ConfChangeTransition
- func (c *ConfChangeV2) LeaveJoint() bool
- func (*ConfChangeV2) ProtoMessage()
- func (x *ConfChangeV2) ProtoReflect() protoreflect.Message
- func (x *ConfChangeV2) Reset()
- func (x *ConfChangeV2) String() string
- type ConfState
- func (*ConfState) Descriptor() ([]byte, []int)deprecated
- func (cs *ConfState) Equivalent(cs2 *ConfState) error
- func (x *ConfState) GetAutoLeave() bool
- func (x *ConfState) GetLearners() []uint64
- func (x *ConfState) GetLearnersNext() []uint64
- func (x *ConfState) GetVoters() []uint64
- func (x *ConfState) GetVotersOutgoing() []uint64
- func (*ConfState) ProtoMessage()
- func (x *ConfState) ProtoReflect() protoreflect.Message
- func (x *ConfState) Reset()
- func (x *ConfState) String() string
- type Entry
- func (*Entry) Descriptor() ([]byte, []int)deprecated
- func (x *Entry) GetData() []byte
- func (x *Entry) GetIndex() uint64
- func (x *Entry) GetTerm() uint64
- func (x *Entry) GetType() EntryType
- func (*Entry) ProtoMessage()
- func (x *Entry) ProtoReflect() protoreflect.Message
- func (x *Entry) Reset()
- func (x *Entry) String() string
- type EntryType
- func (EntryType) Descriptor() protoreflect.EnumDescriptor
- func (x EntryType) Enum() *EntryType
- func (EntryType) EnumDescriptor() ([]byte, []int)deprecated
- func (x EntryType) Number() protoreflect.EnumNumber
- func (x EntryType) String() string
- func (EntryType) Type() protoreflect.EnumType
- func (x *EntryType) UnmarshalJSON(b []byte) errordeprecated
- type HardState
- func (*HardState) Descriptor() ([]byte, []int)deprecated
- func (x *HardState) GetCommit() uint64
- func (x *HardState) GetTerm() uint64
- func (x *HardState) GetVote() uint64
- func (*HardState) ProtoMessage()
- func (x *HardState) ProtoReflect() protoreflect.Message
- func (x *HardState) Reset()
- func (x *HardState) String() string
- type Message
- func (*Message) Descriptor() ([]byte, []int)deprecated
- func (x *Message) GetCommit() uint64
- func (x *Message) GetContext() []byte
- func (x *Message) GetEntries() []*Entry
- func (x *Message) GetFrom() uint64
- func (x *Message) GetIndex() uint64
- func (x *Message) GetLogTerm() uint64
- func (x *Message) GetReject() bool
- func (x *Message) GetRejectHint() uint64
- func (x *Message) GetResponses() []*Message
- func (x *Message) GetSnapshot() *Snapshot
- func (x *Message) GetTerm() uint64
- func (x *Message) GetTo() uint64
- func (x *Message) GetType() MessageType
- func (x *Message) GetVote() uint64
- func (*Message) ProtoMessage()
- func (x *Message) ProtoReflect() protoreflect.Message
- func (x *Message) Reset()
- func (x *Message) String() string
- type MessageType
- func (MessageType) Descriptor() protoreflect.EnumDescriptor
- func (x MessageType) Enum() *MessageType
- func (MessageType) EnumDescriptor() ([]byte, []int)deprecated
- func (x MessageType) Number() protoreflect.EnumNumber
- func (x MessageType) String() string
- func (MessageType) Type() protoreflect.EnumType
- func (x *MessageType) UnmarshalJSON(b []byte) errordeprecated
- type Snapshot
- type SnapshotMetadata
- func (*SnapshotMetadata) Descriptor() ([]byte, []int)deprecated
- func (x *SnapshotMetadata) GetConfState() *ConfState
- func (x *SnapshotMetadata) GetIndex() uint64
- func (x *SnapshotMetadata) GetTerm() uint64
- func (*SnapshotMetadata) ProtoMessage()
- func (x *SnapshotMetadata) ProtoReflect() protoreflect.Message
- func (x *SnapshotMetadata) Reset()
- func (x *SnapshotMetadata) String() string
Constants ¶
const ( EntryNormal = EntryType_EntryNormal EntryConfChange = EntryType_EntryConfChange EntryConfChangeV2 EntryType = EntryType_EntryConfChangeV2 MsgHup = MessageType_MsgHup MsgBeat = MessageType_MsgBeat MsgProp = MessageType_MsgProp MsgApp = MessageType_MsgApp MsgAppResp = MessageType_MsgAppResp MsgVote = MessageType_MsgVote MsgVoteResp = MessageType_MsgVoteResp MsgSnap = MessageType_MsgSnap MsgHeartbeat = MessageType_MsgHeartbeat MsgHeartbeatResp = MessageType_MsgHeartbeatResp MsgUnreachable = MessageType_MsgUnreachable MsgSnapStatus = MessageType_MsgSnapStatus MsgCheckQuorum = MessageType_MsgCheckQuorum MsgTransferLeader = MessageType_MsgTransferLeader MsgTimeoutNow = MessageType_MsgTimeoutNow MsgReadIndex = MessageType_MsgReadIndex MsgReadIndexResp = MessageType_MsgReadIndexResp MsgPreVote = MessageType_MsgPreVote MsgPreVoteResp = MessageType_MsgPreVoteResp MsgStorageAppend = MessageType_MsgStorageAppend MsgStorageAppendResp = MessageType_MsgStorageAppendResp MsgStorageApply = MessageType_MsgStorageApply MsgStorageApplyResp = MessageType_MsgStorageApplyResp MsgForgetLeader = MessageType_MsgForgetLeader ConfChangeTransitionAuto = ConfChangeTransition_ConfChangeTransitionAuto ConfChangeTransitionJointImplicit = ConfChangeTransition_ConfChangeTransitionJointImplicit ConfChangeTransitionJointExplicit = ConfChangeTransition_ConfChangeTransitionJointExplicit ConfChangeAddNode = ConfChangeType_ConfChangeAddNode ConfChangeRemoveNode = ConfChangeType_ConfChangeRemoveNode ConfChangeUpdateNode = ConfChangeType_ConfChangeUpdateNode ConfChangeAddLearnerNode = ConfChangeType_ConfChangeAddLearnerNode )
Variables ¶
var ( EntryType_name = map[int32]string{ 0: "EntryNormal", 1: "EntryConfChange", 2: "EntryConfChangeV2", } EntryType_value = map[string]int32{ "EntryNormal": 0, "EntryConfChange": 1, "EntryConfChangeV2": 2, } )
Enum value maps for EntryType.
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", 19: "MsgStorageAppend", 20: "MsgStorageAppendResp", 21: "MsgStorageApply", 22: "MsgStorageApplyResp", 23: "MsgForgetLeader", } 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, "MsgStorageAppend": 19, "MsgStorageAppendResp": 20, "MsgStorageApply": 21, "MsgStorageApplyResp": 22, "MsgForgetLeader": 23, } )
Enum value maps for MessageType.
var ( ConfChangeTransition_name = map[int32]string{ 0: "ConfChangeTransitionAuto", 1: "ConfChangeTransitionJointImplicit", 2: "ConfChangeTransitionJointExplicit", } ConfChangeTransition_value = map[string]int32{ "ConfChangeTransitionAuto": 0, "ConfChangeTransitionJointImplicit": 1, "ConfChangeTransitionJointExplicit": 2, } )
Enum value maps for ConfChangeTransition.
var ( ConfChangeType_name = map[int32]string{ 0: "ConfChangeAddNode", 1: "ConfChangeRemoveNode", 2: "ConfChangeUpdateNode", 3: "ConfChangeAddLearnerNode", } ConfChangeType_value = map[string]int32{ "ConfChangeAddNode": 0, "ConfChangeRemoveNode": 1, "ConfChangeUpdateNode": 2, "ConfChangeAddLearnerNode": 3, } )
Enum value maps for ConfChangeType.
var File_raft_proto protoreflect.FileDescriptor
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,omitempty"`
NodeId *uint64 `protobuf:"varint,3,opt,name=node_id,json=nodeId" json:"node_id,omitempty"`
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,omitempty"`
// contains filtered or unexported fields
}
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
deprecated
func (*ConfChange) Descriptor() ([]byte, []int)
Deprecated: Use ConfChange.ProtoReflect.Descriptor instead.
func (*ConfChange) GetContext ¶ added in v3.7.0
func (x *ConfChange) GetContext() []byte
func (*ConfChange) GetId ¶ added in v3.7.0
func (x *ConfChange) GetId() uint64
func (*ConfChange) GetNodeId ¶ added in v3.7.0
func (x *ConfChange) GetNodeId() uint64
func (*ConfChange) GetType ¶ added in v3.7.0
func (x *ConfChange) GetType() ConfChangeType
func (*ConfChange) ProtoMessage ¶
func (*ConfChange) ProtoMessage()
func (*ConfChange) ProtoReflect ¶ added in v3.7.0
func (x *ConfChange) ProtoReflect() protoreflect.Message
func (*ConfChange) Reset ¶
func (x *ConfChange) Reset()
func (*ConfChange) String ¶
func (x *ConfChange) String() string
type ConfChangeI ¶
type ConfChangeI interface {
// AsV2 should always return a non-nil object
AsV2() *ConfChangeV2
// AsV1 should always return a non-nil object
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,omitempty"`
NodeId *uint64 `protobuf:"varint,2,opt,name=node_id,json=nodeId" json:"node_id,omitempty"`
// contains filtered or unexported fields
}
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
deprecated
func (*ConfChangeSingle) Descriptor() ([]byte, []int)
Deprecated: Use ConfChangeSingle.ProtoReflect.Descriptor instead.
func (*ConfChangeSingle) GetNodeId ¶ added in v3.7.0
func (x *ConfChangeSingle) GetNodeId() uint64
func (*ConfChangeSingle) GetType ¶ added in v3.7.0
func (x *ConfChangeSingle) GetType() ConfChangeType
func (*ConfChangeSingle) ProtoMessage ¶
func (*ConfChangeSingle) ProtoMessage()
func (*ConfChangeSingle) ProtoReflect ¶ added in v3.7.0
func (x *ConfChangeSingle) ProtoReflect() protoreflect.Message
func (*ConfChangeSingle) Reset ¶
func (x *ConfChangeSingle) Reset()
func (*ConfChangeSingle) String ¶
func (x *ConfChangeSingle) String() string
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. ConfChangeTransition_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). ConfChangeTransition_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). ConfChangeTransition_ConfChangeTransitionJointExplicit ConfChangeTransition = 2 )
func (ConfChangeTransition) Descriptor ¶ added in v3.7.0
func (ConfChangeTransition) Descriptor() protoreflect.EnumDescriptor
func (ConfChangeTransition) Enum ¶
func (x ConfChangeTransition) Enum() *ConfChangeTransition
func (ConfChangeTransition) EnumDescriptor
deprecated
func (ConfChangeTransition) EnumDescriptor() ([]byte, []int)
Deprecated: Use ConfChangeTransition.Descriptor instead.
func (ConfChangeTransition) Number ¶ added in v3.7.0
func (x ConfChangeTransition) Number() protoreflect.EnumNumber
func (ConfChangeTransition) String ¶
func (x ConfChangeTransition) String() string
func (ConfChangeTransition) Type ¶ added in v3.7.0
func (ConfChangeTransition) Type() protoreflect.EnumType
func (*ConfChangeTransition) UnmarshalJSON
deprecated
func (x *ConfChangeTransition) UnmarshalJSON(b []byte) error
Deprecated: Do not use.
type ConfChangeType ¶
type ConfChangeType int32
const ( ConfChangeType_ConfChangeAddNode ConfChangeType = 0 ConfChangeType_ConfChangeRemoveNode ConfChangeType = 1 ConfChangeType_ConfChangeUpdateNode ConfChangeType = 2 ConfChangeType_ConfChangeAddLearnerNode ConfChangeType = 3 )
func (ConfChangeType) Descriptor ¶ added in v3.7.0
func (ConfChangeType) Descriptor() protoreflect.EnumDescriptor
func (ConfChangeType) Enum ¶
func (x ConfChangeType) Enum() *ConfChangeType
func (ConfChangeType) EnumDescriptor
deprecated
func (ConfChangeType) EnumDescriptor() ([]byte, []int)
Deprecated: Use ConfChangeType.Descriptor instead.
func (ConfChangeType) Number ¶ added in v3.7.0
func (x ConfChangeType) Number() protoreflect.EnumNumber
func (ConfChangeType) String ¶
func (x ConfChangeType) String() string
func (ConfChangeType) Type ¶ added in v3.7.0
func (ConfChangeType) Type() protoreflect.EnumType
func (*ConfChangeType) UnmarshalJSON
deprecated
func (x *ConfChangeType) UnmarshalJSON(b []byte) error
Deprecated: Do not use.
type ConfChangeV2 ¶
type ConfChangeV2 struct {
Transition *ConfChangeTransition `protobuf:"varint,1,opt,name=transition,enum=raftpb.ConfChangeTransition" json:"transition,omitempty"`
Changes []*ConfChangeSingle `protobuf:"bytes,2,rep,name=changes" json:"changes,omitempty"`
Context []byte `protobuf:"bytes,3,opt,name=context" json:"context,omitempty"`
// contains filtered or unexported fields
}
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 nil and false.
func (*ConfChangeV2) Descriptor
deprecated
func (*ConfChangeV2) Descriptor() ([]byte, []int)
Deprecated: Use ConfChangeV2.ProtoReflect.Descriptor instead.
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) GetChanges ¶ added in v3.7.0
func (x *ConfChangeV2) GetChanges() []*ConfChangeSingle
func (*ConfChangeV2) GetContext ¶ added in v3.7.0
func (x *ConfChangeV2) GetContext() []byte
func (*ConfChangeV2) GetTransition ¶ added in v3.7.0
func (x *ConfChangeV2) GetTransition() ConfChangeTransition
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) ProtoMessage ¶
func (*ConfChangeV2) ProtoMessage()
func (*ConfChangeV2) ProtoReflect ¶ added in v3.7.0
func (x *ConfChangeV2) ProtoReflect() protoreflect.Message
func (*ConfChangeV2) Reset ¶
func (x *ConfChangeV2) Reset()
func (*ConfChangeV2) String ¶
func (x *ConfChangeV2) String() string
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,omitempty"`
// contains filtered or unexported fields
}
func EnsureConfState ¶ added in v3.7.0
EnsureConfState ensures that cs and all of its pointer fields are non-nil. If cs is nil, a new ConfState is allocated. Any nil pointer field is set to point to its zero value. Returns the resulting cs.
func (*ConfState) Descriptor
deprecated
func (*ConfState) Equivalent ¶
Equivalent returns a nil error if the inputs describe the same configuration. On mismatch, returns a descriptive error showing the differences.
func (*ConfState) GetAutoLeave ¶ added in v3.7.0
func (*ConfState) GetLearners ¶ added in v3.7.0
func (*ConfState) GetLearnersNext ¶ added in v3.7.0
func (*ConfState) GetVotersOutgoing ¶ added in v3.7.0
func (*ConfState) ProtoMessage ¶
func (*ConfState) ProtoMessage()
func (*ConfState) ProtoReflect ¶ added in v3.7.0
func (x *ConfState) ProtoReflect() protoreflect.Message
type Entry ¶
type Entry struct {
Term *uint64 `protobuf:"varint,2,opt,name=Term" json:"Term,omitempty"`
Index *uint64 `protobuf:"varint,3,opt,name=Index" json:"Index,omitempty"`
Type *EntryType `protobuf:"varint,1,opt,name=Type,enum=raftpb.EntryType" json:"Type,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data" json:"Data,omitempty"`
// contains filtered or unexported fields
}
func (*Entry) Descriptor
deprecated
func (*Entry) ProtoMessage ¶
func (*Entry) ProtoMessage()
func (*Entry) ProtoReflect ¶ added in v3.7.0
func (x *Entry) ProtoReflect() protoreflect.Message
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.
func (EntryType) Descriptor ¶ added in v3.7.0
func (EntryType) Descriptor() protoreflect.EnumDescriptor
func (EntryType) EnumDescriptor
deprecated
func (EntryType) Number ¶ added in v3.7.0
func (x EntryType) Number() protoreflect.EnumNumber
func (EntryType) Type ¶ added in v3.7.0
func (EntryType) Type() protoreflect.EnumType
func (*EntryType) UnmarshalJSON
deprecated
type HardState ¶
type HardState struct {
Term *uint64 `protobuf:"varint,1,opt,name=term" json:"term,omitempty"`
Vote *uint64 `protobuf:"varint,2,opt,name=vote" json:"vote,omitempty"`
Commit *uint64 `protobuf:"varint,3,opt,name=commit" json:"commit,omitempty"`
// contains filtered or unexported fields
}
func (*HardState) Descriptor
deprecated
func (*HardState) ProtoMessage ¶
func (*HardState) ProtoMessage()
func (*HardState) ProtoReflect ¶ added in v3.7.0
func (x *HardState) ProtoReflect() protoreflect.Message
type Message ¶
type Message struct {
Type *MessageType `protobuf:"varint,1,opt,name=type,enum=raftpb.MessageType" json:"type,omitempty"`
To *uint64 `protobuf:"varint,2,opt,name=to" json:"to,omitempty"`
From *uint64 `protobuf:"varint,3,opt,name=from" json:"from,omitempty"`
Term *uint64 `protobuf:"varint,4,opt,name=term" json:"term,omitempty"`
// logTerm is generally used for appending Raft logs to followers. For example,
// (type=MsgApp,index=100,logTerm=5) means the leader appends entries starting
// at index=101, and the term of the entry at index 100 is 5.
// (type=MsgAppResp,reject=true,index=100,logTerm=5) means follower rejects some
// entries from its leader as it already has an entry with term 5 at index 100.
// (type=MsgStorageAppendResp,index=100,logTerm=5) means the local node wrote
// entries up to index=100 in stable storage, and the term of the entry at index
// 100 was 5. This doesn't always mean that the corresponding MsgStorageAppend
// message was the one that carried these entries, just that those entries were
// stable at the time of processing the corresponding MsgStorageAppend.
LogTerm *uint64 `protobuf:"varint,5,opt,name=logTerm" json:"logTerm,omitempty"`
Index *uint64 `protobuf:"varint,6,opt,name=index" json:"index,omitempty"`
Entries []*Entry `protobuf:"bytes,7,rep,name=entries" json:"entries,omitempty"`
Commit *uint64 `protobuf:"varint,8,opt,name=commit" json:"commit,omitempty"`
// (type=MsgStorageAppend,vote=5,term=10) means the local node is voting for
// peer 5 in term 10. For MsgStorageAppends, the term, vote, and commit fields
// will either all be set (to facilitate the construction of a HardState) if
// any of the fields have changed or will all be unset if none of the fields
// have changed.
Vote *uint64 `protobuf:"varint,13,opt,name=vote" json:"vote,omitempty"`
// snapshot is non-nil and non-empty for MsgSnap messages and nil for all other
// message types. However, peer nodes running older binary versions may send a
// non-nil, empty value for the snapshot field of non-MsgSnap messages. Code
// should be prepared to handle such messages.
Snapshot *Snapshot `protobuf:"bytes,9,opt,name=snapshot" json:"snapshot,omitempty"`
Reject *bool `protobuf:"varint,10,opt,name=reject" json:"reject,omitempty"`
RejectHint *uint64 `protobuf:"varint,11,opt,name=rejectHint" json:"rejectHint,omitempty"`
Context []byte `protobuf:"bytes,12,opt,name=context" json:"context,omitempty"`
// responses are populated by a raft node to instruct storage threads on how
// to respond and who to respond to when the work associated with a message
// is complete. Populated for MsgStorageAppend and MsgStorageApply messages.
Responses []*Message `protobuf:"bytes,14,rep,name=responses" json:"responses,omitempty"`
// contains filtered or unexported fields
}
func (*Message) Descriptor
deprecated
func (*Message) GetContext ¶ added in v3.7.0
func (*Message) GetEntries ¶ added in v3.7.0
func (*Message) GetLogTerm ¶ added in v3.7.0
func (*Message) GetRejectHint ¶ added in v3.7.0
func (*Message) GetResponses ¶ added in v3.7.0
func (*Message) GetSnapshot ¶ added in v3.7.0
func (*Message) GetType ¶ added in v3.7.0
func (x *Message) GetType() MessageType
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶ added in v3.7.0
func (x *Message) ProtoReflect() protoreflect.Message
type MessageType ¶
type MessageType int32
For description of different message types, see: https://pkg.go.dev/go.etcd.io/raft/v3#hdr-MessageType
const ( MessageType_MsgHup MessageType = 0 MessageType_MsgBeat MessageType = 1 MessageType_MsgProp MessageType = 2 MessageType_MsgApp MessageType = 3 MessageType_MsgAppResp MessageType = 4 MessageType_MsgVote MessageType = 5 MessageType_MsgVoteResp MessageType = 6 MessageType_MsgSnap MessageType = 7 MessageType_MsgHeartbeat MessageType = 8 MessageType_MsgHeartbeatResp MessageType = 9 MessageType_MsgUnreachable MessageType = 10 MessageType_MsgSnapStatus MessageType = 11 MessageType_MsgCheckQuorum MessageType = 12 MessageType_MsgTransferLeader MessageType = 13 MessageType_MsgTimeoutNow MessageType = 14 MessageType_MsgReadIndex MessageType = 15 MessageType_MsgReadIndexResp MessageType = 16 MessageType_MsgPreVote MessageType = 17 MessageType_MsgPreVoteResp MessageType = 18 MessageType_MsgStorageAppend MessageType = 19 MessageType_MsgStorageAppendResp MessageType = 20 MessageType_MsgStorageApply MessageType = 21 MessageType_MsgStorageApplyResp MessageType = 22 MessageType_MsgForgetLeader MessageType = 23 )
func (MessageType) Descriptor ¶ added in v3.7.0
func (MessageType) Descriptor() protoreflect.EnumDescriptor
func (MessageType) Enum ¶
func (x MessageType) Enum() *MessageType
func (MessageType) EnumDescriptor
deprecated
func (MessageType) EnumDescriptor() ([]byte, []int)
Deprecated: Use MessageType.Descriptor instead.
func (MessageType) Number ¶ added in v3.7.0
func (x MessageType) Number() protoreflect.EnumNumber
func (MessageType) String ¶
func (x MessageType) String() string
func (MessageType) Type ¶ added in v3.7.0
func (MessageType) Type() protoreflect.EnumType
func (*MessageType) UnmarshalJSON
deprecated
func (x *MessageType) UnmarshalJSON(b []byte) error
Deprecated: Do not use.
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,omitempty"`
// contains filtered or unexported fields
}
func EnsureSnapshot ¶ added in v3.7.0
EnsureSnapshot ensures that s and all of its pointer fields are non-nil. If s is nil, a new Snapshot is allocated. Any nil pointer field is set to point to its zero value. Returns the resulting s.
func (*Snapshot) Descriptor
deprecated
func (*Snapshot) GetMetadata ¶ added in v3.7.0
func (x *Snapshot) GetMetadata() *SnapshotMetadata
func (*Snapshot) ProtoMessage ¶
func (*Snapshot) ProtoMessage()
func (*Snapshot) ProtoReflect ¶ added in v3.7.0
func (x *Snapshot) ProtoReflect() protoreflect.Message
type SnapshotMetadata ¶
type SnapshotMetadata struct {
ConfState *ConfState `protobuf:"bytes,1,opt,name=conf_state,json=confState" json:"conf_state,omitempty"`
Index *uint64 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
Term *uint64 `protobuf:"varint,3,opt,name=term" json:"term,omitempty"`
// contains filtered or unexported fields
}
func EnsureSnapshotMetadata ¶ added in v3.7.0
func EnsureSnapshotMetadata(m *SnapshotMetadata) *SnapshotMetadata
EnsureSnapshotMetadata ensures that m and all of its pointer fields are non-nil. If m is nil, a new SnapshotMetadata is allocated. Any nil pointer field is set to point to its zero value. Returns the resulting m.
func (*SnapshotMetadata) Descriptor
deprecated
func (*SnapshotMetadata) Descriptor() ([]byte, []int)
Deprecated: Use SnapshotMetadata.ProtoReflect.Descriptor instead.
func (*SnapshotMetadata) GetConfState ¶ added in v3.7.0
func (x *SnapshotMetadata) GetConfState() *ConfState
func (*SnapshotMetadata) GetIndex ¶ added in v3.7.0
func (x *SnapshotMetadata) GetIndex() uint64
func (*SnapshotMetadata) GetTerm ¶ added in v3.7.0
func (x *SnapshotMetadata) GetTerm() uint64
func (*SnapshotMetadata) ProtoMessage ¶
func (*SnapshotMetadata) ProtoMessage()
func (*SnapshotMetadata) ProtoReflect ¶ added in v3.7.0
func (x *SnapshotMetadata) ProtoReflect() protoreflect.Message
func (*SnapshotMetadata) Reset ¶
func (x *SnapshotMetadata) Reset()
func (*SnapshotMetadata) String ¶
func (x *SnapshotMetadata) String() string