agent

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Follower Role = iota
	Candidate
	Leader

	InvalidLockHolderID int32 = -1
	InvalidAgentID      int32 = -1
	NoopAgentID         int32 = -2
)

Variables

View Source
var (
	DemotedToFollower error
	LogMismatch       error
)

Functions

func AppendLog

func AppendLog(logEntry *LogEntry) error

func BroadcastHeartBeat

func BroadcastHeartBeat() error

func Init

func Init(id int32, ge []string, ps PersistentStore)

func IsLeader

func IsLeader() bool

func LeaderID

func LeaderID() int32

func LockHolderID

func LockHolderID() int32

func PendingApplyLogExist

func PendingApplyLogExist() bool

func StartRPCServer

func StartRPCServer(port int)

Types

type LogEntry

type LogEntry struct {
	Term         int64
	LockHolderID int32
	Reserved     int32
}

type PersistentStore

type PersistentStore interface {
	CurrentTerm() int64
	PutCurrentTerm(int64)
	VotedFor() int32
	PutVotedFor(int32)
	LogEntry(int64) *LogEntry
	LogSize() int64
	AppendLog(*LogEntry)
	CutOffLogTail(int64)
}

type RaftServerImpl

type RaftServerImpl struct {
	sfrpc.UnimplementedRaftServer
}

func (*RaftServerImpl) AppendEntries

func (*RaftServerImpl) RequestVote

type Role

type Role int32

type StateMachine

type StateMachine struct {
	LockHolderID int32
}

type VolatileLeaderState

type VolatileLeaderState struct {
	// contains filtered or unexported fields
}

type VolatileState

type VolatileState struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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