api

package
v0.0.0-...-78a91e9 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_raft_v1beta1_append_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_client_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_log_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_service_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_time_proto protoreflect.FileDescriptor
View Source
var File_raft_v1beta1_vote_proto protoreflect.FileDescriptor
View Source
var NullEntry = &LogEntry{Index: 0, Term: 0, Name: "", 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: "Commit",
			Handler:    _Raft_Commit_Handler,
		},
		{
			MethodName: "RequestVote",
			Handler:    _Raft_RequestVote_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "AppendEntries",
			Handler:       _Raft_AppendEntries_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "raft/v1beta1/service.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      string `protobuf:"bytes,1,opt,name=remote,proto3" json:"remote,omitempty"`            // Identity of the follower
	Term        uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`               // Epoch the follower is currently in
	Success     bool   `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`         // If entries were appended or not
	Index       uint64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`             // Latest index in follower's log
	CommitIndex uint64 `protobuf:"varint,5,opt,name=commitIndex,proto3" json:"commitIndex,omitempty"` // The commit index of follower
	// contains filtered or unexported fields
}

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

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"`                 // Epoch of the leader
	Leader       string      `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"`              // Identity of the leader
	PrevLogIndex uint64      `protobuf:"varint,3,opt,name=prevLogIndex,proto3" json:"prevLogIndex,omitempty"` // Latest index in leader's log
	PrevLogTerm  uint64      `protobuf:"varint,4,opt,name=prevLogTerm,proto3" json:"prevLogTerm,omitempty"`   // Epoch of the leader's prev log entry
	LeaderCommit uint64      `protobuf:"varint,5,opt,name=leaderCommit,proto3" json:"leaderCommit,omitempty"` // The commit index of the leader for local commit
	Entries      []*LogEntry `protobuf:"bytes,6,rep,name=entries,proto3" json:"entries,omitempty"`            // Entries to append to the remote's log
	// contains filtered or unexported fields
}

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

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 CommitReply

type CommitReply struct {
	Success  bool      `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	Redirect string    `protobuf:"bytes,2,opt,name=redirect,proto3" json:"redirect,omitempty"`
	Error    string    `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	Entry    *LogEntry `protobuf:"bytes,4,opt,name=entry,proto3" json:"entry,omitempty"`
	// contains filtered or unexported fields
}

func (*CommitReply) Descriptor deprecated

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

Deprecated: Use CommitReply.ProtoReflect.Descriptor instead.

func (*CommitReply) GetEntry

func (x *CommitReply) GetEntry() *LogEntry

func (*CommitReply) GetError

func (x *CommitReply) GetError() string

func (*CommitReply) GetRedirect

func (x *CommitReply) GetRedirect() string

func (*CommitReply) GetSuccess

func (x *CommitReply) GetSuccess() bool

func (*CommitReply) ProtoMessage

func (*CommitReply) ProtoMessage()

func (*CommitReply) ProtoReflect

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

func (*CommitReply) Reset

func (x *CommitReply) Reset()

func (*CommitReply) String

func (x *CommitReply) String() string

type CommitRequest

type CommitRequest struct {
	Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
	Name     string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Value    []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*CommitRequest) Descriptor deprecated

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

Deprecated: Use CommitRequest.ProtoReflect.Descriptor instead.

func (*CommitRequest) GetIdentity

func (x *CommitRequest) GetIdentity() string

func (*CommitRequest) GetName

func (x *CommitRequest) GetName() string

func (*CommitRequest) GetValue

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

func (*CommitRequest) ProtoMessage

func (*CommitRequest) ProtoMessage()

func (*CommitRequest) ProtoReflect

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

func (*CommitRequest) Reset

func (x *CommitRequest) Reset()

func (*CommitRequest) String

func (x *CommitRequest) String() string

type LogEntry

type LogEntry struct {
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` // The expected position of the log entry
	Term  uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`   // The term of the log entry
	Name  string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`    // The name of the command or object
	Value []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`  // The value of the object or command (nil for noop)
	// contains filtered or unexported fields
}

Defines an entry in the log

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) GetName

func (x *LogEntry) GetName() string

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=lastApplied,proto3" json:"lastApplied,omitempty"` // The index of the last applied entry
	CommitIndex uint64 `protobuf:"varint,2,opt,name=commitIndex,proto3" json:"commitIndex,omitempty"` // The index of the last committed entry
	Length      uint64 `protobuf:"varint,3,opt,name=length,proto3" json:"length,omitempty"`           // Number of entries in the log
	Created     *Time  `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"`          // Timestamp the log was created
	Updated     *Time  `protobuf:"bytes,5,opt,name=updated,proto3" json:"updated,omitempty"`          // Timestamp the log was last updated
	// contains filtered or unexported fields
}

Defines meta data for the log

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() *Time

func (*LogMeta) GetLastApplied

func (x *LogMeta) GetLastApplied() uint64

func (*LogMeta) GetLength

func (x *LogMeta) GetLength() uint64

func (*LogMeta) GetUpdated

func (x *LogMeta) GetUpdated() *Time

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 LogSnapshot

type LogSnapshot struct {
	Meta    *LogMeta    `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"`       // the meta data of the log
	Entries []*LogEntry `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries,omitempty"` // the entries in the snapshot
	// contains filtered or unexported fields
}

A complete log (entries and meta) that is written to disk but cannot be modified in place, e.g. has to be written in its entirety.

func (*LogSnapshot) Descriptor deprecated

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

Deprecated: Use LogSnapshot.ProtoReflect.Descriptor instead.

func (*LogSnapshot) GetEntries

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

func (*LogSnapshot) GetMeta

func (x *LogSnapshot) GetMeta() *LogMeta

func (*LogSnapshot) ProtoMessage

func (*LogSnapshot) ProtoMessage()

func (*LogSnapshot) ProtoReflect

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

func (*LogSnapshot) Reset

func (x *LogSnapshot) Reset()

func (*LogSnapshot) String

func (x *LogSnapshot) String() string

type RaftClient

type RaftClient interface {
	Commit(ctx context.Context, in *CommitRequest, opts ...grpc.CallOption) (*CommitReply, error)
	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 {
	Commit(context.Context, *CommitRequest) (*CommitReply, error)
	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 Time

type Time struct {
	Rfc3339 []byte `protobuf:"bytes,1,opt,name=rfc3339,proto3" json:"rfc3339,omitempty"`
	// contains filtered or unexported fields
}

Serializes a time.Time object as an RFC 3339 encoded string.

func FromTime

func FromTime(ts time.Time) *Time

FromTime creates a pb.Time message from a time.Time timestamp.

func (*Time) Descriptor deprecated

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

Deprecated: Use Time.ProtoReflect.Descriptor instead.

func (*Time) Get

func (t *Time) Get() (time.Time, error)

Get the time.Time from the protobuf message.

func (*Time) GetRfc3339

func (x *Time) GetRfc3339() []byte

func (*Time) ProtoMessage

func (*Time) ProtoMessage()

func (*Time) ProtoReflect

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

func (*Time) Reset

func (x *Time) Reset()

func (*Time) Set

func (t *Time) Set(ts time.Time) (err error)

Set the time.Time from the protobuf message.

func (*Time) String

func (x *Time) String() string

type UnimplementedRaftServer

type UnimplementedRaftServer struct {
}

UnimplementedRaftServer must be embedded to have forward compatible implementations.

func (UnimplementedRaftServer) AppendEntries

func (UnimplementedRaftServer) Commit

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  string `protobuf:"bytes,1,opt,name=remote,proto3" json:"remote,omitempty"`    // Identity of the follower
	Term    uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`       // Current epoch of the follower
	Granted bool   `protobuf:"varint,3,opt,name=granted,proto3" json:"granted,omitempty"` // At least one vote is granted
	// contains filtered or unexported fields
}

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

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 epoch the candidate wants to be in
	Candidate    string `protobuf:"bytes,2,opt,name=candidate,proto3" json:"candidate,omitempty"`        // The identity of the candidate
	LastLogIndex uint64 `protobuf:"varint,3,opt,name=lastLogIndex,proto3" json:"lastLogIndex,omitempty"` // The last index in the candidate's log
	LastLogTerm  uint64 `protobuf:"varint,4,opt,name=lastLogTerm,proto3" json:"lastLogTerm,omitempty"`   // The last epoch in the candidate's log
	// contains filtered or unexported fields
}

func (*VoteRequest) Descriptor deprecated

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

Deprecated: Use VoteRequest.ProtoReflect.Descriptor instead.

func (*VoteRequest) GetCandidate

func (x *VoteRequest) GetCandidate() string

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