cluster

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAckCommand

func ApplyAckCommand(raft *raft.Raft, ack *proto.Ack) raft.ApplyFuture

ApplyAckCommand applies a command to save ack a task to the Raft log.

func ApplySaveTaskCommand

func ApplySaveTaskCommand(raft *raft.Raft, task *proto.Task) raft.ApplyFuture

ApplySaveTaskCommand applies a command to save a task to the Raft log.

Types

type LeaderHandle

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

func NewHandle

func NewHandle(tracker *LeaderTracker, grpcPort int) (*LeaderHandle, error)

func (*LeaderHandle) AdminClient

func (lh *LeaderHandle) AdminClient() (proto.AdminClient, error)

func (*LeaderHandle) IsLeader

func (lh *LeaderHandle) IsLeader() bool

func (*LeaderHandle) LeaderAddress

func (lh *LeaderHandle) LeaderAddress() string

func (*LeaderHandle) QueueClient

func (lh *LeaderHandle) QueueClient() (proto.QueueClient, error)

type LeaderTracker

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

func NewTracker

func NewTracker(raft *raft.Raft, selfServerID string) *LeaderTracker

func (*LeaderTracker) AddObserver

func (lsc *LeaderTracker) AddObserver(handler leaderObserver)

AddObserver adds a handler to be called when leadership changes.

func (*LeaderTracker) IsLeader

func (lsc *LeaderTracker) IsLeader() bool

func (*LeaderTracker) LeaderAddress

func (lsc *LeaderTracker) LeaderAddress() string

type Peer

type Peer struct {
	Raft *raft.Raft
	// contains filtered or unexported fields
}

Peer controls a node's membership in the raft cluster.

func NewPeer

func NewPeer(config PeerConfig) (*Peer, error)

func (*Peer) Close

func (p *Peer) Close() error

Close stops the raft server and flushes writes to disk.

This method must be called before the application terminates.

func (*Peer) LoadHandle added in v0.2.0

func (p *Peer) LoadHandle(handle *LeaderHandle)

type PeerConfig

type PeerConfig struct {
	ID               string
	Port             int
	AdvertiseAddr    string
	DataDir          string
	LogBatchSize     int
	BootstrapCluster bool
	DB               *storage.PebbleClient
	Tasks            *storage.TaskStore
	Settings         *storage.SettingStore
	Writer           q.TaskWriter
	SQLPort          int
	QueuePort        int
}

PeerConfig defines how a node will take part in the raft cluster.

Jump to

Keyboard shortcuts

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