Documentation ¶
Index ¶
- Variables
- func RegisterRaftServer(s grpc.ServiceRegistrar, srv RaftServer)
- type AppendDataReq
- type AppendDataResp
- func (*AppendDataResp) Descriptor() ([]byte, []int)deprecated
- func (x *AppendDataResp) GetErrorMessage() string
- func (x *AppendDataResp) GetSuccess() bool
- func (*AppendDataResp) ProtoMessage()
- func (x *AppendDataResp) ProtoReflect() protoreflect.Message
- func (x *AppendDataResp) Reset()
- func (x *AppendDataResp) String() string
- type AppendEntriesReq
- func (*AppendEntriesReq) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntriesReq) GetEntries() []*Log
- func (x *AppendEntriesReq) GetLeaderCommit() uint64
- func (x *AppendEntriesReq) GetLeaderId() string
- func (x *AppendEntriesReq) GetPrevLogIndex() uint64
- func (x *AppendEntriesReq) GetPrevLogTerm() uint64
- func (x *AppendEntriesReq) GetTerm() uint64
- func (*AppendEntriesReq) ProtoMessage()
- func (x *AppendEntriesReq) ProtoReflect() protoreflect.Message
- func (x *AppendEntriesReq) Reset()
- func (x *AppendEntriesReq) String() string
- type AppendEntriesResp
- func (*AppendEntriesResp) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntriesResp) GetSuccess() bool
- func (x *AppendEntriesResp) GetTerm() uint64
- func (*AppendEntriesResp) ProtoMessage()
- func (x *AppendEntriesResp) ProtoReflect() protoreflect.Message
- func (x *AppendEntriesResp) Reset()
- func (x *AppendEntriesResp) String() string
- type KV
- type KVList
- type Log
- type RaftClient
- type RaftServer
- type RequestVoteReq
- func (*RequestVoteReq) Descriptor() ([]byte, []int)deprecated
- func (x *RequestVoteReq) GetCandidateId() string
- func (x *RequestVoteReq) GetLastLogIndex() uint64
- func (x *RequestVoteReq) GetLastLogTerm() uint64
- func (x *RequestVoteReq) GetTerm() uint64
- func (*RequestVoteReq) ProtoMessage()
- func (x *RequestVoteReq) ProtoReflect() protoreflect.Message
- func (x *RequestVoteReq) Reset()
- func (x *RequestVoteReq) String() string
- type RequestVoteResp
- func (*RequestVoteResp) Descriptor() ([]byte, []int)deprecated
- func (x *RequestVoteResp) GetTerm() uint64
- func (x *RequestVoteResp) GetVoteGranted() bool
- func (*RequestVoteResp) ProtoMessage()
- func (x *RequestVoteResp) ProtoReflect() protoreflect.Message
- func (x *RequestVoteResp) Reset()
- func (x *RequestVoteResp) String() string
- type Role
- type UnimplementedRaftServer
- func (UnimplementedRaftServer) AppendData(context.Context, *AppendDataReq) (*AppendDataResp, error)
- func (UnimplementedRaftServer) AppendEntries(context.Context, *AppendEntriesReq) (*AppendEntriesResp, error)
- func (UnimplementedRaftServer) RequestVote(context.Context, *RequestVoteReq) (*RequestVoteResp, error)
- type UnsafeRaftServer
Constants ¶
This section is empty.
Variables ¶
var ( Role_name = map[int32]string{ 0: "FOLLOWER", 1: "CANDIDATE", 2: "LEADER", } Role_value = map[string]int32{ "FOLLOWER": 0, "CANDIDATE": 1, "LEADER": 2, } )
Enum value maps for Role.
var File_proto_konsen_proto protoreflect.FileDescriptor
var File_proto_raft_proto protoreflect.FileDescriptor
var Raft_ServiceDesc = grpc.ServiceDesc{ ServiceName: "konsen.Raft", HandlerType: (*RaftServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "AppendEntries", Handler: _Raft_AppendEntries_Handler, }, { MethodName: "RequestVote", Handler: _Raft_RequestVote_Handler, }, { MethodName: "AppendData", Handler: _Raft_AppendData_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/raft.proto", }
Raft_ServiceDesc is the grpc.ServiceDesc for Raft service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterRaftServer ¶
func RegisterRaftServer(s grpc.ServiceRegistrar, srv RaftServer)
Types ¶
type AppendDataReq ¶
type AppendDataReq struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // Raw data/command that is to be stored and applied to state machine. // contains filtered or unexported fields }
func (*AppendDataReq) Descriptor
deprecated
func (*AppendDataReq) Descriptor() ([]byte, []int)
Deprecated: Use AppendDataReq.ProtoReflect.Descriptor instead.
func (*AppendDataReq) GetData ¶
func (x *AppendDataReq) GetData() []byte
func (*AppendDataReq) ProtoMessage ¶
func (*AppendDataReq) ProtoMessage()
func (*AppendDataReq) ProtoReflect ¶
func (x *AppendDataReq) ProtoReflect() protoreflect.Message
func (*AppendDataReq) Reset ¶
func (x *AppendDataReq) Reset()
func (*AppendDataReq) String ¶
func (x *AppendDataReq) String() string
type AppendDataResp ¶
type AppendDataResp struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` // contains filtered or unexported fields }
func (*AppendDataResp) Descriptor
deprecated
func (*AppendDataResp) Descriptor() ([]byte, []int)
Deprecated: Use AppendDataResp.ProtoReflect.Descriptor instead.
func (*AppendDataResp) GetErrorMessage ¶
func (x *AppendDataResp) GetErrorMessage() string
func (*AppendDataResp) GetSuccess ¶
func (x *AppendDataResp) GetSuccess() bool
func (*AppendDataResp) ProtoMessage ¶
func (*AppendDataResp) ProtoMessage()
func (*AppendDataResp) ProtoReflect ¶
func (x *AppendDataResp) ProtoReflect() protoreflect.Message
func (*AppendDataResp) Reset ¶
func (x *AppendDataResp) Reset()
func (*AppendDataResp) String ¶
func (x *AppendDataResp) String() string
type AppendEntriesReq ¶
type AppendEntriesReq struct { Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` // Leader's term. LeaderId string `protobuf:"bytes,2,opt,name=leader_id,json=leaderId,proto3" json:"leader_id,omitempty"` // So follower can redirect client. PrevLogIndex uint64 `protobuf:"varint,3,opt,name=prev_log_index,json=prevLogIndex,proto3" json:"prev_log_index,omitempty"` // Index of log entry immediately preceding new ones. PrevLogTerm uint64 `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm,proto3" json:"prev_log_term,omitempty"` // Term of prevLogIndex entry. Entries []*Log `protobuf:"bytes,5,rep,name=entries,proto3" json:"entries,omitempty"` // Log entries to datastore (empty for heartbeat; may send more than one for efficiency). LeaderCommit uint64 `protobuf:"varint,6,opt,name=leader_commit,json=leaderCommit,proto3" json:"leader_commit,omitempty"` // Leader's commitIndex. // contains filtered or unexported fields }
func (*AppendEntriesReq) Descriptor
deprecated
func (*AppendEntriesReq) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntriesReq.ProtoReflect.Descriptor instead.
func (*AppendEntriesReq) GetEntries ¶
func (x *AppendEntriesReq) GetEntries() []*Log
func (*AppendEntriesReq) GetLeaderCommit ¶
func (x *AppendEntriesReq) GetLeaderCommit() uint64
func (*AppendEntriesReq) GetLeaderId ¶
func (x *AppendEntriesReq) GetLeaderId() string
func (*AppendEntriesReq) GetPrevLogIndex ¶
func (x *AppendEntriesReq) GetPrevLogIndex() uint64
func (*AppendEntriesReq) GetPrevLogTerm ¶
func (x *AppendEntriesReq) GetPrevLogTerm() uint64
func (*AppendEntriesReq) GetTerm ¶
func (x *AppendEntriesReq) GetTerm() uint64
func (*AppendEntriesReq) ProtoMessage ¶
func (*AppendEntriesReq) ProtoMessage()
func (*AppendEntriesReq) ProtoReflect ¶
func (x *AppendEntriesReq) ProtoReflect() protoreflect.Message
func (*AppendEntriesReq) Reset ¶
func (x *AppendEntriesReq) Reset()
func (*AppendEntriesReq) String ¶
func (x *AppendEntriesReq) String() string
type AppendEntriesResp ¶
type AppendEntriesResp struct { Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` // Current term, for leader to update itself. Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"` // True if follower contained entry matching prevLogIndex and prevLogTerm. // contains filtered or unexported fields }
func (*AppendEntriesResp) Descriptor
deprecated
func (*AppendEntriesResp) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntriesResp.ProtoReflect.Descriptor instead.
func (*AppendEntriesResp) GetSuccess ¶
func (x *AppendEntriesResp) GetSuccess() bool
func (*AppendEntriesResp) GetTerm ¶
func (x *AppendEntriesResp) GetTerm() uint64
func (*AppendEntriesResp) ProtoMessage ¶
func (*AppendEntriesResp) ProtoMessage()
func (*AppendEntriesResp) ProtoReflect ¶
func (x *AppendEntriesResp) ProtoReflect() protoreflect.Message
func (*AppendEntriesResp) Reset ¶
func (x *AppendEntriesResp) Reset()
func (*AppendEntriesResp) String ¶
func (x *AppendEntriesResp) String() string
type KV ¶
type KV struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*KV) Descriptor
deprecated
func (*KV) ProtoMessage ¶
func (*KV) ProtoMessage()
func (*KV) ProtoReflect ¶
func (x *KV) ProtoReflect() protoreflect.Message
type KVList ¶
type KVList struct { KvList []*KV `protobuf:"bytes,1,rep,name=kv_list,json=kvList,proto3" json:"kv_list,omitempty"` // contains filtered or unexported fields }
func (*KVList) Descriptor
deprecated
func (*KVList) ProtoMessage ¶
func (*KVList) ProtoMessage()
func (*KVList) ProtoReflect ¶
func (x *KVList) ProtoReflect() protoreflect.Message
type Log ¶
type Log struct { Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` // Index of the log entry (first index is 1). Term uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"` // Term of the log entry. Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // Raw data/command that the log entry encapsulates. // contains filtered or unexported fields }
func (*Log) Descriptor
deprecated
func (*Log) ProtoMessage ¶
func (*Log) ProtoMessage()
func (*Log) ProtoReflect ¶
func (x *Log) ProtoReflect() protoreflect.Message
type RaftClient ¶
type RaftClient interface { // Sends "AppendEntries" request. AppendEntries(ctx context.Context, in *AppendEntriesReq, opts ...grpc.CallOption) (*AppendEntriesResp, error) // Sends "RequestVote" request. RequestVote(ctx context.Context, in *RequestVoteReq, opts ...grpc.CallOption) (*RequestVoteResp, error) // Sends "AppendData" request. AppendData(ctx context.Context, in *AppendDataReq, opts ...grpc.CallOption) (*AppendDataResp, error) }
RaftClient is the client API for Raft service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewRaftClient ¶
func NewRaftClient(cc grpc.ClientConnInterface) RaftClient
type RaftServer ¶
type RaftServer interface { // Sends "AppendEntries" request. AppendEntries(context.Context, *AppendEntriesReq) (*AppendEntriesResp, error) // Sends "RequestVote" request. RequestVote(context.Context, *RequestVoteReq) (*RequestVoteResp, error) // Sends "AppendData" request. AppendData(context.Context, *AppendDataReq) (*AppendDataResp, error) // contains filtered or unexported methods }
RaftServer is the server API for Raft service. All implementations must embed UnimplementedRaftServer for forward compatibility
type RequestVoteReq ¶
type RequestVoteReq struct { Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` // Candidate's term. CandidateId string `protobuf:"bytes,2,opt,name=candidate_id,json=candidateId,proto3" json:"candidate_id,omitempty"` // Candidate requesting vote. LastLogIndex uint64 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"` // Index of candidate's last log entry. LastLogTerm uint64 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,omitempty"` // Term of candidate's last log entry. // contains filtered or unexported fields }
func (*RequestVoteReq) Descriptor
deprecated
func (*RequestVoteReq) Descriptor() ([]byte, []int)
Deprecated: Use RequestVoteReq.ProtoReflect.Descriptor instead.
func (*RequestVoteReq) GetCandidateId ¶
func (x *RequestVoteReq) GetCandidateId() string
func (*RequestVoteReq) GetLastLogIndex ¶
func (x *RequestVoteReq) GetLastLogIndex() uint64
func (*RequestVoteReq) GetLastLogTerm ¶
func (x *RequestVoteReq) GetLastLogTerm() uint64
func (*RequestVoteReq) GetTerm ¶
func (x *RequestVoteReq) GetTerm() uint64
func (*RequestVoteReq) ProtoMessage ¶
func (*RequestVoteReq) ProtoMessage()
func (*RequestVoteReq) ProtoReflect ¶
func (x *RequestVoteReq) ProtoReflect() protoreflect.Message
func (*RequestVoteReq) Reset ¶
func (x *RequestVoteReq) Reset()
func (*RequestVoteReq) String ¶
func (x *RequestVoteReq) String() string
type RequestVoteResp ¶
type RequestVoteResp struct { Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"` // Current term, for candidate to update itself. VoteGranted bool `protobuf:"varint,2,opt,name=vote_granted,json=voteGranted,proto3" json:"vote_granted,omitempty"` // True means candidate received vote. // contains filtered or unexported fields }
func (*RequestVoteResp) Descriptor
deprecated
func (*RequestVoteResp) Descriptor() ([]byte, []int)
Deprecated: Use RequestVoteResp.ProtoReflect.Descriptor instead.
func (*RequestVoteResp) GetTerm ¶
func (x *RequestVoteResp) GetTerm() uint64
func (*RequestVoteResp) GetVoteGranted ¶
func (x *RequestVoteResp) GetVoteGranted() bool
func (*RequestVoteResp) ProtoMessage ¶
func (*RequestVoteResp) ProtoMessage()
func (*RequestVoteResp) ProtoReflect ¶
func (x *RequestVoteResp) ProtoReflect() protoreflect.Message
func (*RequestVoteResp) Reset ¶
func (x *RequestVoteResp) Reset()
func (*RequestVoteResp) String ¶
func (x *RequestVoteResp) String() string
type Role ¶
type Role int32
func (Role) Descriptor ¶
func (Role) Descriptor() protoreflect.EnumDescriptor
func (Role) EnumDescriptor
deprecated
func (Role) Number ¶
func (x Role) Number() protoreflect.EnumNumber
func (Role) Type ¶
func (Role) Type() protoreflect.EnumType
type UnimplementedRaftServer ¶
type UnimplementedRaftServer struct { }
UnimplementedRaftServer must be embedded to have forward compatible implementations.
func (UnimplementedRaftServer) AppendData ¶
func (UnimplementedRaftServer) AppendData(context.Context, *AppendDataReq) (*AppendDataResp, error)
func (UnimplementedRaftServer) AppendEntries ¶
func (UnimplementedRaftServer) AppendEntries(context.Context, *AppendEntriesReq) (*AppendEntriesResp, error)
func (UnimplementedRaftServer) RequestVote ¶
func (UnimplementedRaftServer) RequestVote(context.Context, *RequestVoteReq) (*RequestVoteResp, error)
type UnsafeRaftServer ¶
type UnsafeRaftServer interface {
// contains filtered or unexported methods
}
UnsafeRaftServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RaftServer will result in compilation errors.