coordinator

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MasterCfg

type MasterCfg struct {
	// basic
	Ctx  context.Context
	TTL  int64 // masterController elect keepalive ttl
	Node models.Node
	Repo state.Repository

	// factory
	DiscoveryFactory discovery.Factory
	RepoFactory      state.RepositoryFactory
}

MasterCfg represents the config for masterController creating

type MasterController

type MasterController interface {
	// Start starts master do election master, if success build master context,
	// starts state machine do cluster coordinate such metadata, cluster state etc.
	Start() error
	// IsMaster returns current node if is master
	IsMaster() bool
	// GetMaster returns the current master info
	GetMaster() *models.Master
	// Stop stops master if current node is master, cleanup master context and stops state machine
	Stop()
	// FlushDatabase submits the coordinator task for flushing memory database by cluster and database name
	FlushDatabase(cluster string, databaseName string) error
	// GetStateManager returns master's state manager.
	GetStateManager() masterpkg.StateManager
	// WatchMasterElected adds callback after master finished election.
	WatchMasterElected(fn func(master *models.Master))
}

MasterController represents all metadata/state controller, only has one active master in broker cluster. MasterController will control all storage cluster metadata, update state, then notify each broker node.

func NewMasterController

func NewMasterController(cfg *MasterCfg) MasterController

NewMasterController create MasterController for current node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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