v1

package
v0.0.0-...-8e51596 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_raft_v1_raft_proto protoreflect.FileDescriptor
View Source
var RaftService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "raft.v1.RaftService",
	HandlerType: (*RaftServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "RequestVote",
			Handler:    _RaftService_RequestVote_Handler,
		},
		{
			MethodName: "AppendEntries",
			Handler:    _RaftService_AppendEntries_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "raft/v1/raft.proto",
}

RaftService_ServiceDesc is the grpc.ServiceDesc for RaftService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRaftServiceServer

func RegisterRaftServiceServer(s grpc.ServiceRegistrar, srv RaftServiceServer)

Types

type AppendEntriesRequest

type AppendEntriesRequest struct {

	// leader’s term
	Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// so follower can redirect clients
	LeaderId int64 `protobuf:"varint,2,opt,name=leader_id,json=leaderId,proto3" json:"leader_id,omitempty"`
	// index of log entry immediately preceding new ones
	PrevLogIndex int64 `protobuf:"varint,3,opt,name=prev_log_index,json=prevLogIndex,proto3" json:"prev_log_index,omitempty"`
	// term of prevLogIndex entry
	PrevLogTerm int64 `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm,proto3" json:"prev_log_term,omitempty"`
	// log entries to store (empty for heartbeat; may send more than one for efficiency)
	Entries []*LogEntry `protobuf:"bytes,5,rep,name=entries,proto3" json:"entries,omitempty"`
	// leader’s commitIndex
	LeaderCommit int64 `protobuf:"varint,6,opt,name=leader_commit,json=leaderCommit,proto3" json:"leader_commit,omitempty"`
	// contains filtered or unexported fields
}

The request payload for AppendEntries

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() int64

func (*AppendEntriesRequest) GetLeaderId

func (x *AppendEntriesRequest) GetLeaderId() int64

func (*AppendEntriesRequest) GetPrevLogIndex

func (x *AppendEntriesRequest) GetPrevLogIndex() int64

func (*AppendEntriesRequest) GetPrevLogTerm

func (x *AppendEntriesRequest) GetPrevLogTerm() int64

func (*AppendEntriesRequest) GetTerm

func (x *AppendEntriesRequest) GetTerm() int64

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 {

	// currentTerm, for leader to update itself
	Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// true if follower contained entry matching prevLogIndex and prevLogTerm
	Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"`
	// contains filtered or unexported fields
}

The response body for AppendEntries

func (*AppendEntriesResponse) Descriptor deprecated

func (*AppendEntriesResponse) Descriptor() ([]byte, []int)

Deprecated: Use AppendEntriesResponse.ProtoReflect.Descriptor instead.

func (*AppendEntriesResponse) GetSuccess

func (x *AppendEntriesResponse) GetSuccess() bool

func (*AppendEntriesResponse) GetTerm

func (x *AppendEntriesResponse) GetTerm() int64

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 LogEntry

type LogEntry struct {

	// command
	Command []byte `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	// term
	Term int64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`
	// contains filtered or unexported fields
}

LogEntry

func (*LogEntry) Descriptor deprecated

func (*LogEntry) Descriptor() ([]byte, []int)

Deprecated: Use LogEntry.ProtoReflect.Descriptor instead.

func (*LogEntry) GetCommand

func (x *LogEntry) GetCommand() []byte

func (*LogEntry) GetTerm

func (x *LogEntry) GetTerm() int64

func (*LogEntry) ProtoMessage

func (*LogEntry) ProtoMessage()

func (*LogEntry) ProtoReflect

func (x *LogEntry) ProtoReflect() protoreflect.Message

func (*LogEntry) Reset

func (x *LogEntry) Reset()

func (*LogEntry) String

func (x *LogEntry) String() string

type RaftServiceClient

type RaftServiceClient interface {
	// Invoked by candidates to gather votes
	RequestVote(ctx context.Context, in *RequestVoteRequest, opts ...grpc.CallOption) (*RequestVoteResponse, error)
	// Invoked by leader to replicate log entries; also used as heartbeat
	AppendEntries(ctx context.Context, in *AppendEntriesRequest, opts ...grpc.CallOption) (*AppendEntriesResponse, error)
}

RaftServiceClient is the client API for RaftService 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.

type RaftServiceServer

type RaftServiceServer interface {
	// Invoked by candidates to gather votes
	RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteResponse, error)
	// Invoked by leader to replicate log entries; also used as heartbeat
	AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
}

RaftServiceServer is the server API for RaftService service. All implementations should embed UnimplementedRaftServiceServer for forward compatibility

type RequestVoteRequest

type RequestVoteRequest struct {

	// candidate’s term
	Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// candidate requesting vote
	CandidateId int64 `protobuf:"varint,2,opt,name=candidate_id,json=candidateId,proto3" json:"candidate_id,omitempty"`
	// index of candidate’s last log entry
	LastLogIndex int64 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"`
	// term of candidate’s last log entry
	LastLogTerm int64 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,omitempty"`
	// contains filtered or unexported fields
}

The request payload for RequestVote

func (*RequestVoteRequest) Descriptor deprecated

func (*RequestVoteRequest) Descriptor() ([]byte, []int)

Deprecated: Use RequestVoteRequest.ProtoReflect.Descriptor instead.

func (*RequestVoteRequest) GetCandidateId

func (x *RequestVoteRequest) GetCandidateId() int64

func (*RequestVoteRequest) GetLastLogIndex

func (x *RequestVoteRequest) GetLastLogIndex() int64

func (*RequestVoteRequest) GetLastLogTerm

func (x *RequestVoteRequest) GetLastLogTerm() int64

func (*RequestVoteRequest) GetTerm

func (x *RequestVoteRequest) GetTerm() int64

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 RequestVoteResponse

type RequestVoteResponse struct {

	// currentTerm, for candidate to update itself
	Term int64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// true means candidate received vote
	VoteGranted bool `protobuf:"varint,2,opt,name=vote_granted,json=voteGranted,proto3" json:"vote_granted,omitempty"`
	// contains filtered or unexported fields
}

The response body for RequestVote

func (*RequestVoteResponse) Descriptor deprecated

func (*RequestVoteResponse) Descriptor() ([]byte, []int)

Deprecated: Use RequestVoteResponse.ProtoReflect.Descriptor instead.

func (*RequestVoteResponse) GetTerm

func (x *RequestVoteResponse) GetTerm() int64

func (*RequestVoteResponse) GetVoteGranted

func (x *RequestVoteResponse) GetVoteGranted() bool

func (*RequestVoteResponse) ProtoMessage

func (*RequestVoteResponse) ProtoMessage()

func (*RequestVoteResponse) ProtoReflect

func (x *RequestVoteResponse) ProtoReflect() protoreflect.Message

func (*RequestVoteResponse) Reset

func (x *RequestVoteResponse) Reset()

func (*RequestVoteResponse) String

func (x *RequestVoteResponse) String() string

type UnimplementedRaftServiceServer

type UnimplementedRaftServiceServer struct {
}

UnimplementedRaftServiceServer should be embedded to have forward compatible implementations.

func (UnimplementedRaftServiceServer) AppendEntries

func (UnimplementedRaftServiceServer) RequestVote

type UnsafeRaftServiceServer

type UnsafeRaftServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeRaftServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RaftServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL