raft

package
v0.0.0-...-4ab98ed Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: CC0-1.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RolodexRaft_AppendEntries_FullMethodName = "/raft.RolodexRaft/AppendEntries"
	RolodexRaft_RequestVote_FullMethodName   = "/raft.RolodexRaft/RequestVote"
	RolodexRaft_Discover_FullMethodName      = "/raft.RolodexRaft/Discover"
)

Variables

View Source
var File_raft_raft_proto protoreflect.FileDescriptor
View Source
var RolodexRaft_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "raft.RolodexRaft",
	HandlerType: (*RolodexRaftServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "AppendEntries",
			Handler:    _RolodexRaft_AppendEntries_Handler,
		},
		{
			MethodName: "RequestVote",
			Handler:    _RolodexRaft_RequestVote_Handler,
		},
		{
			MethodName: "Discover",
			Handler:    _RolodexRaft_Discover_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "raft/raft.proto",
}

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

Functions

func Main

func Main(port *int, discoveryUrl *string)

func RegisterRolodexRaftServer

func RegisterRolodexRaftServer(s grpc.ServiceRegistrar, srv RolodexRaftServer)

Types

type AppendEntriesRequest

type AppendEntriesRequest struct {
	Term         int32       `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	LeaderId     string      `protobuf:"bytes,2,opt,name=leader_id,json=leaderId,proto3" json:"leader_id,omitempty"`
	PrevLogIndex int32       `protobuf:"varint,3,opt,name=prev_log_index,json=prevLogIndex,proto3" json:"prev_log_index,omitempty"`
	PrevLogTerm  int32       `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm,proto3" json:"prev_log_term,omitempty"`
	Entries      []*LogEntry `protobuf:"bytes,5,rep,name=entries,proto3" json:"entries,omitempty"`
	LeaderCommit int32       `protobuf:"varint,6,opt,name=leader_commit,json=leaderCommit,proto3" json:"leader_commit,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() string

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"`
	// contains filtered or unexported fields
}

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

type DiscoverRequest struct {
	Members []string `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"`
	// contains filtered or unexported fields
}

func (*DiscoverRequest) Descriptor deprecated

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

Deprecated: Use DiscoverRequest.ProtoReflect.Descriptor instead.

func (*DiscoverRequest) GetMembers

func (x *DiscoverRequest) GetMembers() []string

func (*DiscoverRequest) ProtoMessage

func (*DiscoverRequest) ProtoMessage()

func (*DiscoverRequest) ProtoReflect

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

func (*DiscoverRequest) Reset

func (x *DiscoverRequest) Reset()

func (*DiscoverRequest) String

func (x *DiscoverRequest) String() string

type DiscoverResponse

type DiscoverResponse struct {
	Members []string `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"`
	Caller  string   `protobuf:"bytes,2,opt,name=caller,proto3" json:"caller,omitempty"`
	// contains filtered or unexported fields
}

func (*DiscoverResponse) Descriptor deprecated

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

Deprecated: Use DiscoverResponse.ProtoReflect.Descriptor instead.

func (*DiscoverResponse) GetCaller

func (x *DiscoverResponse) GetCaller() string

func (*DiscoverResponse) GetMembers

func (x *DiscoverResponse) GetMembers() []string

func (*DiscoverResponse) ProtoMessage

func (*DiscoverResponse) ProtoMessage()

func (*DiscoverResponse) ProtoReflect

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

func (*DiscoverResponse) Reset

func (x *DiscoverResponse) Reset()

func (*DiscoverResponse) String

func (x *DiscoverResponse) String() string

type LogEntry

type LogEntry struct {
	Term    int32  `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	Index   int32  `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
	Command string `protobuf:"bytes,3,opt,name=command,proto3" json:"command,omitempty"`
	Key     string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"`
	Value   string `protobuf:"bytes,5,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) GetCommand

func (x *LogEntry) GetCommand() string

func (*LogEntry) GetIndex

func (x *LogEntry) GetIndex() int32

func (*LogEntry) GetKey

func (x *LogEntry) GetKey() string

func (*LogEntry) GetTerm

func (x *LogEntry) GetTerm() int32

func (*LogEntry) GetValue

func (x *LogEntry) GetValue() string

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 RaftServer

type RaftServer struct {
	RolodexRaftServer
	// contains filtered or unexported fields
}

func NewRaftServer

func NewRaftServer() *RaftServer

func StartServer

func StartServer(port *int, signals chan bool) *RaftServer

func (*RaftServer) AppendEntries

func (raftServer *RaftServer) AppendEntries(ctx context.Context, req *AppendEntriesRequest) (*AppendEntriesResponse, error)

func (*RaftServer) Discover

func (raftServer *RaftServer) Discover(ctx context.Context, req *DiscoverRequest) (*DiscoverResponse, error)

func (*RaftServer) RequestVote

func (raftServer *RaftServer) RequestVote(ctx context.Context, req *RequestVoteRequest) (*RequestVoteResponse, error)

func (*RaftServer) StartDiscovery

func (raftServer *RaftServer) StartDiscovery(discoveryUrl *string)

func (*RaftServer) StartRaft

func (raftServer *RaftServer) StartRaft()

type RequestVoteRequest

type RequestVoteRequest struct {
	Term         int32  `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	CandidateId  string `protobuf:"bytes,2,opt,name=candidate_id,json=candidateId,proto3" json:"candidate_id,omitempty"`
	LastLogIndex int32  `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"`
	LastLogTerm  int32  `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,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() string

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 RequestVoteResponse

type RequestVoteResponse struct {
	Term        int32 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	VoteGranted bool  `protobuf:"varint,2,opt,name=vote_granted,json=voteGranted,proto3" json:"vote_granted,omitempty"`
	// contains filtered or unexported fields
}

func (*RequestVoteResponse) Descriptor deprecated

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

Deprecated: Use RequestVoteResponse.ProtoReflect.Descriptor instead.

func (*RequestVoteResponse) GetTerm

func (x *RequestVoteResponse) GetTerm() int32

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 RolodexRaftClient

type RolodexRaftClient interface {
	AppendEntries(ctx context.Context, in *AppendEntriesRequest, opts ...grpc.CallOption) (*AppendEntriesResponse, error)
	RequestVote(ctx context.Context, in *RequestVoteRequest, opts ...grpc.CallOption) (*RequestVoteResponse, error)
	Discover(ctx context.Context, in *DiscoverRequest, opts ...grpc.CallOption) (*DiscoverResponse, error)
}

RolodexRaftClient is the client API for RolodexRaft 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 RolodexRaftServer

type RolodexRaftServer interface {
	AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
	RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteResponse, error)
	Discover(context.Context, *DiscoverRequest) (*DiscoverResponse, error)
	// contains filtered or unexported methods
}

RolodexRaftServer is the server API for RolodexRaft service. All implementations must embed UnimplementedRolodexRaftServer for forward compatibility

type ServerState

type ServerState int
const (
	LEADER ServerState = iota
	FOLLOWER
	CANDIDATE
	PENDING
)

type UnimplementedRolodexRaftServer

type UnimplementedRolodexRaftServer struct {
}

UnimplementedRolodexRaftServer must be embedded to have forward compatible implementations.

func (UnimplementedRolodexRaftServer) AppendEntries

func (UnimplementedRolodexRaftServer) Discover

func (UnimplementedRolodexRaftServer) RequestVote

type UnsafeRolodexRaftServer

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

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

Jump to

Keyboard shortcuts

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