api

package
v0.12.8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Raft_RequestVote_FullMethodName   = "/raft.v1beta1.Raft/RequestVote"
	Raft_AppendEntries_FullMethodName = "/raft.v1beta1.Raft/AppendEntries"
)

Variables

View Source
var File_raft_v1beta1_log_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_raft_proto protoreflect.FileDescriptor
View Source
var NullEntry = &LogEntry{Index: 0, Term: 0, Key: nil, Value: nil}

NullEntry is an empty entry that is appended to the log.

View Source
var Raft_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "raft.v1beta1.Raft",
	HandlerType: (*RaftServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "RequestVote",
			Handler:    _Raft_RequestVote_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "AppendEntries",
			Handler:       _Raft_AppendEntries_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "raft/v1beta1/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 AppendReply

type AppendReply struct {
	Remote      uint32 `protobuf:"varint,1,opt,name=remote,proto3" json:"remote,omitempty"`                              // the PID of the follower
	Term        uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`                                  // the term of the follower
	Success     bool   `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`                            // if the operation was successful
	Index       uint64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`                                // the last index of the follower's log
	CommitIndex uint64 `protobuf:"varint,5,opt,name=commit_index,json=commitIndex,proto3" json:"commit_index,omitempty"` // the commit index of the follower's log
	// contains filtered or unexported fields
}

Sent from followers back to the leader to acknowledge the append entries or heartbeat and to update the leader with their local state.

func (*AppendReply) Descriptor deprecated

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

Deprecated: Use AppendReply.ProtoReflect.Descriptor instead.

func (*AppendReply) GetCommitIndex

func (x *AppendReply) GetCommitIndex() uint64

func (*AppendReply) GetIndex

func (x *AppendReply) GetIndex() uint64

func (*AppendReply) GetRemote

func (x *AppendReply) GetRemote() uint32

func (*AppendReply) GetSuccess

func (x *AppendReply) GetSuccess() bool

func (*AppendReply) GetTerm

func (x *AppendReply) GetTerm() uint64

func (*AppendReply) ProtoMessage

func (*AppendReply) ProtoMessage()

func (*AppendReply) ProtoReflect

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

func (*AppendReply) Reset

func (x *AppendReply) Reset()

func (*AppendReply) String

func (x *AppendReply) String() string

type AppendRequest

type AppendRequest struct {
	Term         uint64      `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`                                       // the term of the leader
	Leader       uint32      `protobuf:"varint,2,opt,name=leader,proto3" json:"leader,omitempty"`                                   // the PID of the leader
	PrevLogIndex uint64      `protobuf:"varint,3,opt,name=prev_log_index,json=prevLogIndex,proto3" json:"prev_log_index,omitempty"` // the index of the previous log entry in the leader's log
	PrevLogTerm  uint64      `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm,proto3" json:"prev_log_term,omitempty"`    // the term of the previous log entry in the leader's log
	LeaderCommit uint64      `protobuf:"varint,5,opt,name=leader_commit,json=leaderCommit,proto3" json:"leader_commit,omitempty"`   // the index of the last commited entry in the leader's log
	Entries      []*LogEntry `protobuf:"bytes,6,rep,name=entries,proto3" json:"entries,omitempty"`                                  // the entries to be appended to the follower's log
	// contains filtered or unexported fields
}

Sent from the leader to the peers in the quorum to update their logs, or if no entries are sent, as a heartbeat message.

func (*AppendRequest) Descriptor deprecated

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

Deprecated: Use AppendRequest.ProtoReflect.Descriptor instead.

func (*AppendRequest) GetEntries

func (x *AppendRequest) GetEntries() []*LogEntry

func (*AppendRequest) GetLeader

func (x *AppendRequest) GetLeader() uint32

func (*AppendRequest) GetLeaderCommit

func (x *AppendRequest) GetLeaderCommit() uint64

func (*AppendRequest) GetPrevLogIndex

func (x *AppendRequest) GetPrevLogIndex() uint64

func (*AppendRequest) GetPrevLogTerm

func (x *AppendRequest) GetPrevLogTerm() uint64

func (*AppendRequest) GetTerm

func (x *AppendRequest) GetTerm() uint64

func (*AppendRequest) ProtoMessage

func (*AppendRequest) ProtoMessage()

func (*AppendRequest) ProtoReflect

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

func (*AppendRequest) Reset

func (x *AppendRequest) Reset()

func (*AppendRequest) String

func (x *AppendRequest) String() string

type LogEntry

type LogEntry struct {
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	Term  uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`
	Key   []byte `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*LogEntry) Descriptor deprecated

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

Deprecated: Use LogEntry.ProtoReflect.Descriptor instead.

func (*LogEntry) GetIndex

func (x *LogEntry) GetIndex() uint64

func (*LogEntry) GetKey

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

func (*LogEntry) GetTerm

func (x *LogEntry) GetTerm() uint64

func (*LogEntry) GetValue

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

func (*LogEntry) IsZero

func (e *LogEntry) IsZero() bool

IsZero returns true if the entry is the null entry.

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 LogMeta

type LogMeta struct {
	LastApplied uint64                 `protobuf:"varint,1,opt,name=last_applied,json=lastApplied,proto3" json:"last_applied,omitempty"`
	CommitIndex uint64                 `protobuf:"varint,2,opt,name=commit_index,json=commitIndex,proto3" json:"commit_index,omitempty"`
	Length      uint64                 `protobuf:"varint,3,opt,name=length,proto3" json:"length,omitempty"`
	Created     *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"`
	Modified    *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=modified,proto3" json:"modified,omitempty"`
	Snapshot    *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=snapshot,proto3" json:"snapshot,omitempty"`
	// contains filtered or unexported fields
}

func (*LogMeta) Descriptor deprecated

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

Deprecated: Use LogMeta.ProtoReflect.Descriptor instead.

func (*LogMeta) GetCommitIndex

func (x *LogMeta) GetCommitIndex() uint64

func (*LogMeta) GetCreated

func (x *LogMeta) GetCreated() *timestamppb.Timestamp

func (*LogMeta) GetLastApplied

func (x *LogMeta) GetLastApplied() uint64

func (*LogMeta) GetLength

func (x *LogMeta) GetLength() uint64

func (*LogMeta) GetModified

func (x *LogMeta) GetModified() *timestamppb.Timestamp

func (*LogMeta) GetSnapshot

func (x *LogMeta) GetSnapshot() *timestamppb.Timestamp

func (*LogMeta) ProtoMessage

func (*LogMeta) ProtoMessage()

func (*LogMeta) ProtoReflect

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

func (*LogMeta) Reset

func (x *LogMeta) Reset()

func (*LogMeta) String

func (x *LogMeta) String() string

type RaftClient

type RaftClient interface {
	RequestVote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteReply, error)
	AppendEntries(ctx context.Context, opts ...grpc.CallOption) (Raft_AppendEntriesClient, 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 {
	RequestVote(context.Context, *VoteRequest) (*VoteReply, error)
	AppendEntries(Raft_AppendEntriesServer) error
	// contains filtered or unexported methods
}

RaftServer is the server API for Raft service. All implementations must embed UnimplementedRaftServer for forward compatibility

type Raft_AppendEntriesClient

type Raft_AppendEntriesClient interface {
	Send(*AppendRequest) error
	Recv() (*AppendReply, error)
	grpc.ClientStream
}

type Raft_AppendEntriesServer

type Raft_AppendEntriesServer interface {
	Send(*AppendReply) error
	Recv() (*AppendRequest, error)
	grpc.ServerStream
}

type UnimplementedRaftServer

type UnimplementedRaftServer struct {
}

UnimplementedRaftServer must be embedded to have forward compatible implementations.

func (UnimplementedRaftServer) AppendEntries

func (UnimplementedRaftServer) RequestVote

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.

type VoteReply

type VoteReply struct {
	Remote  uint32 `protobuf:"varint,1,opt,name=remote,proto3" json:"remote,omitempty"`   // the PID of the voter
	Term    uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`       // the current term of voter
	Granted bool   `protobuf:"varint,3,opt,name=granted,proto3" json:"granted,omitempty"` // if the vote is granted or not
	// contains filtered or unexported fields
}

Sent from peers in the quorum in response to a vote request to bring the candidate's state up to date or to elect the candidate as leader for the term.

func (*VoteReply) Descriptor deprecated

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

Deprecated: Use VoteReply.ProtoReflect.Descriptor instead.

func (*VoteReply) GetGranted

func (x *VoteReply) GetGranted() bool

func (*VoteReply) GetRemote

func (x *VoteReply) GetRemote() uint32

func (*VoteReply) GetTerm

func (x *VoteReply) GetTerm() uint64

func (*VoteReply) ProtoMessage

func (*VoteReply) ProtoMessage()

func (*VoteReply) ProtoReflect

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

func (*VoteReply) Reset

func (x *VoteReply) Reset()

func (*VoteReply) String

func (x *VoteReply) String() string

type VoteRequest

type VoteRequest struct {
	Term         uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`                                       // the term of the election
	Candidate    uint32 `protobuf:"varint,2,opt,name=candidate,proto3" json:"candidate,omitempty"`                             // the PID of the candidate requesting the vote
	LastLogIndex uint64 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"` // the last log index of the candidate's log
	LastLogTerm  uint64 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,omitempty"`    // the log of the last entry in the candidate's log
	// contains filtered or unexported fields
}

Sent from a candidate to all peers in the quorum to elect a new Raft leader.

func (*VoteRequest) Descriptor deprecated

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

Deprecated: Use VoteRequest.ProtoReflect.Descriptor instead.

func (*VoteRequest) GetCandidate

func (x *VoteRequest) GetCandidate() uint32

func (*VoteRequest) GetLastLogIndex

func (x *VoteRequest) GetLastLogIndex() uint64

func (*VoteRequest) GetLastLogTerm

func (x *VoteRequest) GetLastLogTerm() uint64

func (*VoteRequest) GetTerm

func (x *VoteRequest) GetTerm() uint64

func (*VoteRequest) ProtoMessage

func (*VoteRequest) ProtoMessage()

func (*VoteRequest) ProtoReflect

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

func (*VoteRequest) Reset

func (x *VoteRequest) Reset()

func (*VoteRequest) String

func (x *VoteRequest) String() string

Jump to

Keyboard shortcuts

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