raftgrpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command func(ctx context.Context, myAddress string, myState State, replicaCount int) error

type ReplicaServer

type ReplicaServer struct {
	protocol.UnimplementedFollowerServer
	// contains filtered or unexported fields
}

func NewReplicaServer

func NewReplicaServer(storage raftstorage.Storage) *ReplicaServer

func (*ReplicaServer) AddCommand

func (rs *ReplicaServer) AddCommand(commandName string, command Command)

func (*ReplicaServer) GetState

func (rs *ReplicaServer) GetState() State

func (*ReplicaServer) GetTerm

func (rs *ReplicaServer) GetTerm() uint64

func (*ReplicaServer) IncomingElectionRequests

func (rs *ReplicaServer) IncomingElectionRequests() chan string

func (*ReplicaServer) IncomingHeartbeats

func (rs *ReplicaServer) IncomingHeartbeats() chan string

func (*ReplicaServer) NewTerm

func (rs *ReplicaServer) NewTerm() uint64

func (*ReplicaServer) SendElectionRequest

func (rs *ReplicaServer) SendElectionRequest(ctx context.Context, request *protocol.ElectionRequest) (*protocol.ElectionResponse, error)

func (*ReplicaServer) SendExecuteCommand

func (rs *ReplicaServer) SendExecuteCommand(ctx context.Context, command *protocol.CommandName) (*protocol.Nothing, error)

func (*ReplicaServer) SendHeartBeat

func (rs *ReplicaServer) SendHeartBeat(ctx context.Context, heartbeatRequest *protocol.HeartbeatRequest) (*protocol.Nothing, error)

func (*ReplicaServer) SetState

func (rs *ReplicaServer) SetState(state State)

type State

type State uint
const (
	Follower State = iota
	Candidate
	Leader
)

func (State) String

func (s State) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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