cluster

package
v0.6.0-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SUCCESS = iota // The request was successful.
	FAILED         // The request failed.
)
View Source
const (
	StartEntities    = "StartEntities"
	StopEntities     = "StopEntities"
	AppDetailsUpdate = "AppDetailsUpdate"
	TakeOverEntities = "TakeOverEntities"
)
View Source
const (
	STOPPED = iota
	RUNNING
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppNames

type AppNames struct {
	Names []string
}

AppNames contains a slice of application names.

type DummySupervisor

type DummySupervisor struct {
}

func (*DummySupervisor) ActivateApp

func (d *DummySupervisor) ActivateApp(app store.App)

Implement if required

func (*DummySupervisor) BootEntity

func (d *DummySupervisor) BootEntity(entity e.EntityInfo, bool bool) error

Implement if required

func (*DummySupervisor) DeactivateApp

func (d *DummySupervisor) DeactivateApp(app store.App)

Implement if required

type EntityIDs

type EntityIDs struct {
	Ids []string
}

EntityIDs contains a slice of entity IDs.

type Option

type Option func(*options)

func WithAddress

func WithAddress(address string) Option

func WithBootStrapServers

func WithBootStrapServers(bootStrapServers []string) Option

func WithClusterName

func WithClusterName(clusterName string) Option

func WithJoinSize

func WithJoinSize(joinSize int) Option

func WithLogEnabled

func WithLogEnabled(logEnabled bool) Option

func WithLogLevels

func WithLogLevels(logLevels map[string]logging.Level) Option

func WithRebalance

func WithRebalance(enabled bool, intervalSeconds int, settleDelaySeconds int) Option

WithRebalance applies rebalancing settings expressed in seconds, as read from configuration. Non-positive durations keep the defaults.

func WithRebalanceEnabled

func WithRebalanceEnabled(rebalanceEnabled bool) Option

WithRebalanceEnabled turns on handing entities a node no longer owns back to their owner. When disabled the node still accepts entities handed to it by peers, so nodes can be switched over one at a time.

func WithRebalanceInterval

func WithRebalanceInterval(rebalanceInterval time.Duration) Option

WithRebalanceInterval sets how often a node hands entities it no longer owns back to their owner, independent of ring change events. Zero disables the periodic sweep; ring changes still trigger rebalancing.

func WithRebalanceSettleDelay

func WithRebalanceSettleDelay(rebalanceSettleDelay time.Duration) Option

WithRebalanceSettleDelay sets how long to wait after a ring change before rebalancing, so a burst of membership flaps results in a single sweep.

func WithReconciliationEnabled

func WithReconciliationEnabled(reconciliationEnabled bool) Option

func WithReconciliationOffset

func WithReconciliationOffset(reconciliationOffset int) Option

func WithReplicaPoints

func WithReplicaPoints(replicaPoints int) Option

func WithStatsD

func WithStatsD(statsD bark.StatsReporter) Option

type RecoverableEntity

type RecoverableEntity struct {
	Obj       cluster_entity.Entity // The underlying entity.
	Recovered int                   // The number of times the entity was recovered.
	// contains filtered or unexported fields
}

RecoverableEntity is a wrapper for a recoverable entity.

func (RecoverableEntity) Init

func (r RecoverableEntity) Init() error

Init initializes the recoverable entity before its asynchronous start.

func (RecoverableEntity) Start

func (r RecoverableEntity) Start()

Start runs an initialized recoverable entity.

func (RecoverableEntity) Stop

func (r RecoverableEntity) Stop()

Stop stops the recoverable entity.

type Request

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

Request represents a request to be sent to a remote node.

type Response

type Response struct {
	ServerAddress string   // The server address that sent the response.
	Error         string   // The error message, if any.
	Status        int      // The status of the response.
	Accepted      []string // Entity IDs the responding node took ownership of (TakeOverEntities only).
}

Response represents a response received from a remote node.

type Supervisor

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

noinspection SpellCheckingInspection

func NewSupervisor

func NewSupervisor(entityFactory e.EntityFactory, clusterDao dao.ClusterDao, monitor p.Monitor, opt ...Option) *Supervisor

func (*Supervisor) ActivateApp

func (s *Supervisor) ActivateApp(app store.App)

ActivateApp starts all the pollers for the app Forwards the pollers to start in case destination node is different TODO: Try to combine above methods

func (*Supervisor) AppDetailsUpdateEventHandler

func (s *Supervisor) AppDetailsUpdateEventHandler(ctx json.Context, request *AppNames) (*Response, error)

AppDetailsUpdateEventHandler receives app update event Invalidates cache based on appName

func (*Supervisor) AppDetailsUpdateHandler

func (s *Supervisor) AppDetailsUpdateHandler(appName string)

AppDetailsUpdateHandler invalidates in memory cache

func (*Supervisor) Boot

func (s *Supervisor) Boot()

Boot fetch all the entities from DB and starts them one by one panics and stops the process in case there is any issue in starting any entity

func (*Supervisor) BootEntity

func (s *Supervisor) BootEntity(entity e.EntityInfo, forward bool) (err error)

BootEntity perform following functions 1. Get all reachable members from a node 2. Check the destination node for a entity 3. Start/forward the entity depending on the destination node

func (*Supervisor) CloseRingPop

func (s *Supervisor) CloseRingPop()

Stop ringpop, TChannel gracefully

func (*Supervisor) DeactivateApp

func (s *Supervisor) DeactivateApp(app store.App)

DeactivateApp stops all the pollers for the app Forwards the pollers to stop in case destination node is different

func (*Supervisor) HandleEvent

func (s *Supervisor) HandleEvent(event events.Event)

HandleEvent handle different events emitted by Ringpop TODO: Check all events

func (*Supervisor) InitRingPop

func (s *Supervisor) InitRingPop()

initRingPop initializes ringpop with provided configurations

func (*Supervisor) OffloadOrPanic

func (s *Supervisor) OffloadOrPanic(nodeName string)

Offload perform following functions 1. Get all entities assigned to the offloaded node 2. Check the destination node for a entity 3. Start the entity if the current node is the destination node 4. Reconcile schedules if there was any miss during offloading

func (*Supervisor) RegisterHandler

func (s *Supervisor) RegisterHandler() error

RegisterHandler registers actions against respective methods

func (*Supervisor) StartEntities

func (s *Supervisor) StartEntities(ctx json.Context, request *EntityIDs) (res *Response, err error)

StartEntities iterates over the list of entityIds. Starts the entities on current node if destination node is same as own address or forward the entities to respective destination node

func (*Supervisor) StartEntity

func (s *Supervisor) StartEntity(id string) (bool, error)

StartEntity starts an entity if it is not already running. Adds entity in in-memory concurrent map if the entity does not exist. Updates DB with entity status as Running.

func (*Supervisor) StopEntities

func (s *Supervisor) StopEntities(ctx json.Context, request *EntityIDs) (res *Response, err error)

StopEntities iterates over the list of entityIds. Sops the entities on current node if destination node is same as own address or forward the entities to respective destination node

func (*Supervisor) StopEntity

func (s *Supervisor) StopEntity(id string) (bool, error)

StopEntity stops an entity if it is running. Removes entity from in-memory concurrent map. Updates DB with entity status as stopped.

func (*Supervisor) StopNode

func (s *Supervisor) StopNode()

StopNode stops all the entities assigned to that node before it is brought down

func (*Supervisor) TakeOverEntities

func (s *Supervisor) TakeOverEntities(ctx json.Context, request *EntityIDs) (*Response, error)

TakeOverEntities claims each entity that this node owns according to its own view of the ring and reports the claimed IDs back, so the caller only stops what this node is now running.

func (*Supervisor) WaitForTermination

func (s *Supervisor) WaitForTermination()

WaitForTermination waits for OS signals to terminate Stops the node, closes stastDClient before exiting the program

type SupervisorHandler

type SupervisorHandler interface {
	// BootEntity boots an entity with the specified entity info and reconcile flag.
	BootEntity(e.EntityInfo, bool) error
	// DeactivateApp deactivates the specified application.
	DeactivateApp(app store.App)
	// ActivateApp activates the specified application.
	ActivateApp(app store.App)
}

SupervisorHandler is an interface for a supervisor's handler.

Jump to

Keyboard shortcuts

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