Documentation
¶
Index ¶
- Variables
- func RegisterRaftRpcServer(s grpc.ServiceRegistrar, srv RaftRpcServer)
- type AppendEntriesRequest
- func (*AppendEntriesRequest) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntriesRequest) GetEntries() []*LogEntry
- func (x *AppendEntriesRequest) GetLeaderCommit() int32
- func (x *AppendEntriesRequest) GetLeaderId() int32
- func (x *AppendEntriesRequest) GetPrevLogIndex() int32
- func (x *AppendEntriesRequest) GetPrevLogTerm() int32
- func (x *AppendEntriesRequest) GetTerm() int32
- func (*AppendEntriesRequest) ProtoMessage()
- func (x *AppendEntriesRequest) ProtoReflect() protoreflect.Message
- func (x *AppendEntriesRequest) Reset()
- func (x *AppendEntriesRequest) String() string
- type AppendEntriesResponse
- func (*AppendEntriesResponse) Descriptor() ([]byte, []int)deprecated
- func (x *AppendEntriesResponse) GetPeerId() int32
- func (x *AppendEntriesResponse) GetSuccess() bool
- func (x *AppendEntriesResponse) GetTerm() int32
- func (*AppendEntriesResponse) ProtoMessage()
- func (x *AppendEntriesResponse) ProtoReflect() protoreflect.Message
- func (x *AppendEntriesResponse) Reset()
- func (x *AppendEntriesResponse) String() string
- type Key
- type KeyValuePair
- func (*KeyValuePair) Descriptor() ([]byte, []int)deprecated
- func (x *KeyValuePair) GetKey() string
- func (x *KeyValuePair) GetValue() string
- func (*KeyValuePair) ProtoMessage()
- func (x *KeyValuePair) ProtoReflect() protoreflect.Message
- func (x *KeyValuePair) Reset()
- func (x *KeyValuePair) String() string
- type LogEntry
- type Operation
- func (*Operation) Descriptor() ([]byte, []int)deprecated
- func (x *Operation) GetId() string
- func (x *Operation) GetKey() string
- func (x *Operation) GetType() OperationType
- func (x *Operation) GetValue() string
- func (*Operation) ProtoMessage()
- func (x *Operation) ProtoReflect() protoreflect.Message
- func (x *Operation) Reset()
- func (x *Operation) String() string
- type OperationType
- func (OperationType) Descriptor() protoreflect.EnumDescriptor
- func (x OperationType) Enum() *OperationType
- func (OperationType) EnumDescriptor() ([]byte, []int)deprecated
- func (x OperationType) Number() protoreflect.EnumNumber
- func (x OperationType) String() string
- func (OperationType) Type() protoreflect.EnumType
- type RaftRpcClient
- type RaftRpcServer
- type RequestVoteReply
- func (*RequestVoteReply) Descriptor() ([]byte, []int)deprecated
- func (x *RequestVoteReply) GetPeerId() int32
- func (x *RequestVoteReply) GetTerm() int32
- func (x *RequestVoteReply) GetVoteGranted() bool
- func (*RequestVoteReply) ProtoMessage()
- func (x *RequestVoteReply) ProtoReflect() protoreflect.Message
- func (x *RequestVoteReply) Reset()
- func (x *RequestVoteReply) String() string
- type RequestVoteRequest
- func (*RequestVoteRequest) Descriptor() ([]byte, []int)deprecated
- func (x *RequestVoteRequest) GetCandidateId() int32
- func (x *RequestVoteRequest) GetLastLogIndex() int32
- func (x *RequestVoteRequest) GetLastLogTerm() int32
- func (x *RequestVoteRequest) GetTerm() int32
- func (*RequestVoteRequest) ProtoMessage()
- func (x *RequestVoteRequest) ProtoReflect() protoreflect.Message
- func (x *RequestVoteRequest) Reset()
- func (x *RequestVoteRequest) String() string
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetIsLeader() bool
- func (x *Response) GetNewLeader() int32
- func (x *Response) GetOk() bool
- func (x *Response) GetResponse() string
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type StoredLog
- type StoredVote
- type UnimplementedRaftRpcServer
- func (UnimplementedRaftRpcServer) AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
- func (UnimplementedRaftRpcServer) Delete(context.Context, *Key) (*Response, error)
- func (UnimplementedRaftRpcServer) FastGet(context.Context, *Key) (*Response, error)
- func (UnimplementedRaftRpcServer) Get(context.Context, *Key) (*Response, error)
- func (UnimplementedRaftRpcServer) Partition(context.Context, *wrappers.BoolValue) (*empty.Empty, error)
- func (UnimplementedRaftRpcServer) RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteReply, error)
- func (UnimplementedRaftRpcServer) Set(context.Context, *KeyValuePair) (*Response, error)
- type UnsafeRaftRpcServer
Constants ¶
This section is empty.
Variables ¶
var ( OperationType_name = map[int32]string{ 0: "NOOP", 1: "GET", 2: "SET", 3: "DELETE", 4: "FAST_GET", } OperationType_value = map[string]int32{ "NOOP": 0, "GET": 1, "SET": 2, "DELETE": 3, "FAST_GET": 4, } )
Enum value maps for OperationType.
var File_proto_rpc_proto protoreflect.FileDescriptor
var RaftRpc_ServiceDesc = grpc.ServiceDesc{ ServiceName: "RaftRpc", HandlerType: (*RaftRpcServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Get", Handler: _RaftRpc_Get_Handler, }, { MethodName: "FastGet", Handler: _RaftRpc_FastGet_Handler, }, { MethodName: "Set", Handler: _RaftRpc_Set_Handler, }, { MethodName: "Delete", Handler: _RaftRpc_Delete_Handler, }, { MethodName: "RequestVote", Handler: _RaftRpc_RequestVote_Handler, }, { MethodName: "AppendEntries", Handler: _RaftRpc_AppendEntries_Handler, }, { MethodName: "Partition", Handler: _RaftRpc_Partition_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/rpc.proto", }
RaftRpc_ServiceDesc is the grpc.ServiceDesc for RaftRpc service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterRaftRpcServer ¶
func RegisterRaftRpcServer(s grpc.ServiceRegistrar, srv RaftRpcServer)
Types ¶
type AppendEntriesRequest ¶
type AppendEntriesRequest struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
LeaderId int32 `protobuf:"varint,2,opt,name=leaderId,proto3" json:"leaderId,omitempty"`
PrevLogIndex int32 `protobuf:"varint,3,opt,name=prevLogIndex,proto3" json:"prevLogIndex,omitempty"`
PrevLogTerm int32 `protobuf:"varint,4,opt,name=prevLogTerm,proto3" json:"prevLogTerm,omitempty"`
Entries []*LogEntry `protobuf:"bytes,5,rep,name=entries,proto3" json:"entries,omitempty"`
LeaderCommit int32 `protobuf:"varint,6,opt,name=leaderCommit,proto3" json:"leaderCommit,omitempty"`
// contains filtered or unexported fields
}
func (*AppendEntriesRequest) Descriptor
deprecated
func (*AppendEntriesRequest) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntriesRequest.ProtoReflect.Descriptor instead.
func (*AppendEntriesRequest) GetEntries ¶
func (x *AppendEntriesRequest) GetEntries() []*LogEntry
func (*AppendEntriesRequest) GetLeaderCommit ¶
func (x *AppendEntriesRequest) GetLeaderCommit() int32
func (*AppendEntriesRequest) GetLeaderId ¶
func (x *AppendEntriesRequest) GetLeaderId() int32
func (*AppendEntriesRequest) GetPrevLogIndex ¶
func (x *AppendEntriesRequest) GetPrevLogIndex() int32
func (*AppendEntriesRequest) GetPrevLogTerm ¶
func (x *AppendEntriesRequest) GetPrevLogTerm() int32
func (*AppendEntriesRequest) GetTerm ¶
func (x *AppendEntriesRequest) GetTerm() int32
func (*AppendEntriesRequest) ProtoMessage ¶
func (*AppendEntriesRequest) ProtoMessage()
func (*AppendEntriesRequest) ProtoReflect ¶
func (x *AppendEntriesRequest) ProtoReflect() protoreflect.Message
func (*AppendEntriesRequest) Reset ¶
func (x *AppendEntriesRequest) Reset()
func (*AppendEntriesRequest) String ¶
func (x *AppendEntriesRequest) String() string
type AppendEntriesResponse ¶
type AppendEntriesResponse struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"`
PeerId int32 `protobuf:"varint,3,opt,name=peerId,proto3" json:"peerId,omitempty"`
// contains filtered or unexported fields
}
func (*AppendEntriesResponse) Descriptor
deprecated
func (*AppendEntriesResponse) Descriptor() ([]byte, []int)
Deprecated: Use AppendEntriesResponse.ProtoReflect.Descriptor instead.
func (*AppendEntriesResponse) GetPeerId ¶
func (x *AppendEntriesResponse) GetPeerId() int32
func (*AppendEntriesResponse) GetSuccess ¶
func (x *AppendEntriesResponse) GetSuccess() bool
func (*AppendEntriesResponse) GetTerm ¶
func (x *AppendEntriesResponse) GetTerm() int32
func (*AppendEntriesResponse) ProtoMessage ¶
func (*AppendEntriesResponse) ProtoMessage()
func (*AppendEntriesResponse) ProtoReflect ¶
func (x *AppendEntriesResponse) ProtoReflect() protoreflect.Message
func (*AppendEntriesResponse) Reset ¶
func (x *AppendEntriesResponse) Reset()
func (*AppendEntriesResponse) String ¶
func (x *AppendEntriesResponse) String() string
type Key ¶
type Key struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// contains filtered or unexported fields
}
func (*Key) Descriptor
deprecated
func (*Key) ProtoMessage ¶
func (*Key) ProtoMessage()
func (*Key) ProtoReflect ¶
func (x *Key) ProtoReflect() protoreflect.Message
type KeyValuePair ¶
type KeyValuePair struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
func (*KeyValuePair) Descriptor
deprecated
func (*KeyValuePair) Descriptor() ([]byte, []int)
Deprecated: Use KeyValuePair.ProtoReflect.Descriptor instead.
func (*KeyValuePair) GetKey ¶
func (x *KeyValuePair) GetKey() string
func (*KeyValuePair) GetValue ¶
func (x *KeyValuePair) GetValue() string
func (*KeyValuePair) ProtoMessage ¶
func (*KeyValuePair) ProtoMessage()
func (*KeyValuePair) ProtoReflect ¶
func (x *KeyValuePair) ProtoReflect() protoreflect.Message
func (*KeyValuePair) Reset ¶
func (x *KeyValuePair) Reset()
func (*KeyValuePair) String ¶
func (x *KeyValuePair) String() string
type LogEntry ¶
type LogEntry struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
Operation *Operation `protobuf:"bytes,2,opt,name=operation,proto3" json:"operation,omitempty"`
// contains filtered or unexported fields
}
func (*LogEntry) Descriptor
deprecated
func (*LogEntry) GetOperation ¶
func (*LogEntry) ProtoMessage ¶
func (*LogEntry) ProtoMessage()
func (*LogEntry) ProtoReflect ¶
func (x *LogEntry) ProtoReflect() protoreflect.Message
type Operation ¶
type Operation struct {
Type OperationType `protobuf:"varint,1,opt,name=type,proto3,enum=OperationType" json:"type,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
func (*Operation) Descriptor
deprecated
func (*Operation) GetType ¶
func (x *Operation) GetType() OperationType
func (*Operation) ProtoMessage ¶
func (*Operation) ProtoMessage()
func (*Operation) ProtoReflect ¶
func (x *Operation) ProtoReflect() protoreflect.Message
type OperationType ¶
type OperationType int32
const ( OperationType_NOOP OperationType = 0 OperationType_GET OperationType = 1 OperationType_SET OperationType = 2 OperationType_DELETE OperationType = 3 OperationType_FAST_GET OperationType = 4 )
func (OperationType) Descriptor ¶
func (OperationType) Descriptor() protoreflect.EnumDescriptor
func (OperationType) Enum ¶
func (x OperationType) Enum() *OperationType
func (OperationType) EnumDescriptor
deprecated
func (OperationType) EnumDescriptor() ([]byte, []int)
Deprecated: Use OperationType.Descriptor instead.
func (OperationType) Number ¶
func (x OperationType) Number() protoreflect.EnumNumber
func (OperationType) String ¶
func (x OperationType) String() string
func (OperationType) Type ¶
func (OperationType) Type() protoreflect.EnumType
type RaftRpcClient ¶
type RaftRpcClient interface {
Get(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Response, error)
FastGet(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Response, error)
Set(ctx context.Context, in *KeyValuePair, opts ...grpc.CallOption) (*Response, error)
Delete(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Response, error)
RequestVote(ctx context.Context, in *RequestVoteRequest, opts ...grpc.CallOption) (*RequestVoteReply, error)
AppendEntries(ctx context.Context, in *AppendEntriesRequest, opts ...grpc.CallOption) (*AppendEntriesResponse, error)
Partition(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*empty.Empty, error)
}
RaftRpcClient is the client API for RaftRpc 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 NewRaftRpcClient ¶
func NewRaftRpcClient(cc grpc.ClientConnInterface) RaftRpcClient
type RaftRpcServer ¶
type RaftRpcServer interface {
Get(context.Context, *Key) (*Response, error)
FastGet(context.Context, *Key) (*Response, error)
Set(context.Context, *KeyValuePair) (*Response, error)
Delete(context.Context, *Key) (*Response, error)
RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteReply, error)
AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
Partition(context.Context, *wrappers.BoolValue) (*empty.Empty, error)
// contains filtered or unexported methods
}
RaftRpcServer is the server API for RaftRpc service. All implementations must embed UnimplementedRaftRpcServer for forward compatibility
type RequestVoteReply ¶
type RequestVoteReply struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
VoteGranted bool `protobuf:"varint,2,opt,name=voteGranted,proto3" json:"voteGranted,omitempty"`
PeerId int32 `protobuf:"varint,3,opt,name=peerId,proto3" json:"peerId,omitempty"`
// contains filtered or unexported fields
}
func (*RequestVoteReply) Descriptor
deprecated
func (*RequestVoteReply) Descriptor() ([]byte, []int)
Deprecated: Use RequestVoteReply.ProtoReflect.Descriptor instead.
func (*RequestVoteReply) GetPeerId ¶
func (x *RequestVoteReply) GetPeerId() int32
func (*RequestVoteReply) GetTerm ¶
func (x *RequestVoteReply) GetTerm() int32
func (*RequestVoteReply) GetVoteGranted ¶
func (x *RequestVoteReply) GetVoteGranted() bool
func (*RequestVoteReply) ProtoMessage ¶
func (*RequestVoteReply) ProtoMessage()
func (*RequestVoteReply) ProtoReflect ¶
func (x *RequestVoteReply) ProtoReflect() protoreflect.Message
func (*RequestVoteReply) Reset ¶
func (x *RequestVoteReply) Reset()
func (*RequestVoteReply) String ¶
func (x *RequestVoteReply) String() string
type RequestVoteRequest ¶
type RequestVoteRequest struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
CandidateId int32 `protobuf:"varint,2,opt,name=candidateId,proto3" json:"candidateId,omitempty"`
LastLogIndex int32 `protobuf:"varint,3,opt,name=lastLogIndex,proto3" json:"lastLogIndex,omitempty"`
LastLogTerm int32 `protobuf:"varint,4,opt,name=lastLogTerm,proto3" json:"lastLogTerm,omitempty"`
// contains filtered or unexported fields
}
func (*RequestVoteRequest) Descriptor
deprecated
func (*RequestVoteRequest) Descriptor() ([]byte, []int)
Deprecated: Use RequestVoteRequest.ProtoReflect.Descriptor instead.
func (*RequestVoteRequest) GetCandidateId ¶
func (x *RequestVoteRequest) GetCandidateId() int32
func (*RequestVoteRequest) GetLastLogIndex ¶
func (x *RequestVoteRequest) GetLastLogIndex() int32
func (*RequestVoteRequest) GetLastLogTerm ¶
func (x *RequestVoteRequest) GetLastLogTerm() int32
func (*RequestVoteRequest) GetTerm ¶
func (x *RequestVoteRequest) GetTerm() int32
func (*RequestVoteRequest) ProtoMessage ¶
func (*RequestVoteRequest) ProtoMessage()
func (*RequestVoteRequest) ProtoReflect ¶
func (x *RequestVoteRequest) ProtoReflect() protoreflect.Message
func (*RequestVoteRequest) Reset ¶
func (x *RequestVoteRequest) Reset()
func (*RequestVoteRequest) String ¶
func (x *RequestVoteRequest) String() string
type Response ¶
type Response struct {
Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"`
Response string `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
IsLeader bool `protobuf:"varint,3,opt,name=isLeader,proto3" json:"isLeader,omitempty"`
NewLeader int32 `protobuf:"varint,4,opt,name=newLeader,proto3" json:"newLeader,omitempty"`
// contains filtered or unexported fields
}
func (*Response) Descriptor
deprecated
func (*Response) GetIsLeader ¶
func (*Response) GetNewLeader ¶
func (*Response) GetResponse ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type StoredLog ¶
type StoredLog struct {
Logs []*LogEntry `protobuf:"bytes,1,rep,name=logs,proto3" json:"logs,omitempty"`
// contains filtered or unexported fields
}
func (*StoredLog) Descriptor
deprecated
func (*StoredLog) ProtoMessage ¶
func (*StoredLog) ProtoMessage()
func (*StoredLog) ProtoReflect ¶
func (x *StoredLog) ProtoReflect() protoreflect.Message
type StoredVote ¶
type StoredVote struct {
Term int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
VotedFor int32 `protobuf:"varint,2,opt,name=votedFor,proto3" json:"votedFor,omitempty"`
// contains filtered or unexported fields
}
func (*StoredVote) Descriptor
deprecated
func (*StoredVote) Descriptor() ([]byte, []int)
Deprecated: Use StoredVote.ProtoReflect.Descriptor instead.
func (*StoredVote) GetTerm ¶
func (x *StoredVote) GetTerm() int32
func (*StoredVote) GetVotedFor ¶
func (x *StoredVote) GetVotedFor() int32
func (*StoredVote) ProtoMessage ¶
func (*StoredVote) ProtoMessage()
func (*StoredVote) ProtoReflect ¶
func (x *StoredVote) ProtoReflect() protoreflect.Message
func (*StoredVote) Reset ¶
func (x *StoredVote) Reset()
func (*StoredVote) String ¶
func (x *StoredVote) String() string
type UnimplementedRaftRpcServer ¶
type UnimplementedRaftRpcServer struct {
}
UnimplementedRaftRpcServer must be embedded to have forward compatible implementations.
func (UnimplementedRaftRpcServer) AppendEntries ¶
func (UnimplementedRaftRpcServer) AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
func (UnimplementedRaftRpcServer) RequestVote ¶
func (UnimplementedRaftRpcServer) RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteReply, error)
func (UnimplementedRaftRpcServer) Set ¶
func (UnimplementedRaftRpcServer) Set(context.Context, *KeyValuePair) (*Response, error)
type UnsafeRaftRpcServer ¶
type UnsafeRaftRpcServer interface {
// contains filtered or unexported methods
}
UnsafeRaftRpcServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RaftRpcServer will result in compilation errors.