Documentation
¶
Index ¶
- type ClusterStatus
- type DistributionStrategy
- type Distributor
- func (d *Distributor) AssignSoul(soul *core.Soul) (string, error)
- func (d *Distributor) GetLoadDistribution() map[string]*NodeLoad
- func (d *Distributor) GetNodeForSoul(soulID string) (string, bool)
- func (d *Distributor) GetSoulsForNode(nodeID string) []string
- func (d *Distributor) ReassignSoul(soulID string) error
- func (d *Distributor) RegisterNode(nodeID, region string)
- func (d *Distributor) SetCallbacks(onAssign func(soulID string, nodeID string) error, ...)
- func (d *Distributor) Start()
- func (d *Distributor) Stop()
- func (d *Distributor) UnassignSoul(soulID string)
- func (d *Distributor) UnregisterNode(nodeID string)
- func (d *Distributor) UpdateNodeLoad(nodeID string, cpu, memory float64, soulCount int)
- type Manager
- type NodeLoad
- type SoulMove
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterStatus ¶
type ClusterStatus struct {
IsClustered bool `json:"is_clustered"`
NodeID string `json:"node_id"`
State string `json:"state,omitempty"`
Leader string `json:"leader,omitempty"`
Term uint64 `json:"term,omitempty"`
PeerCount int `json:"peer_count,omitempty"`
}
ClusterStatus contains cluster status information
type DistributionStrategy ¶ added in v0.1.0
type DistributionStrategy int
DistributionStrategy determines how souls are assigned to nodes
const ( // StrategyRoundRobin assigns souls sequentially StrategyRoundRobin DistributionStrategy = iota // StrategyRegionAware prefers nodes in the same region StrategyRegionAware // StrategyLoadBased assigns to least loaded nodes StrategyLoadBased // StrategyHashBased uses consistent hashing StrategyHashBased )
func (DistributionStrategy) String ¶ added in v0.1.0
func (s DistributionStrategy) String() string
String returns the string representation of a strategy
type Distributor ¶ added in v0.1.0
type Distributor struct {
// contains filtered or unexported fields
}
Distributor handles soul assignment across cluster nodes The Scales of Ma'at - weighing and distributing the load
func NewDistributor ¶ added in v0.1.0
func NewDistributor(nodeID, region string, strategy DistributionStrategy, logger *slog.Logger) *Distributor
NewDistributor creates a new distributor
func (*Distributor) AssignSoul ¶ added in v0.1.0
func (d *Distributor) AssignSoul(soul *core.Soul) (string, error)
AssignSoul assigns a soul to a node
func (*Distributor) GetLoadDistribution ¶ added in v0.1.0
func (d *Distributor) GetLoadDistribution() map[string]*NodeLoad
GetLoadDistribution returns current load distribution
func (*Distributor) GetNodeForSoul ¶ added in v0.1.0
func (d *Distributor) GetNodeForSoul(soulID string) (string, bool)
GetNodeForSoul returns the node assigned to a soul
func (*Distributor) GetSoulsForNode ¶ added in v0.1.0
func (d *Distributor) GetSoulsForNode(nodeID string) []string
GetSoulsForNode returns all souls assigned to a node
func (*Distributor) ReassignSoul ¶ added in v0.1.0
func (d *Distributor) ReassignSoul(soulID string) error
ReassignSoul moves a soul to a different node
func (*Distributor) RegisterNode ¶ added in v0.1.0
func (d *Distributor) RegisterNode(nodeID, region string)
RegisterNode registers a node in the cluster
func (*Distributor) SetCallbacks ¶ added in v0.1.0
func (d *Distributor) SetCallbacks( onAssign func(soulID string, nodeID string) error, onUnassign func(soulID string) error, onRebalance func(moves []SoulMove), )
SetCallbacks sets the distribution callbacks
func (*Distributor) Start ¶ added in v0.1.0
func (d *Distributor) Start()
Start starts the distributor
func (*Distributor) UnassignSoul ¶ added in v0.1.0
func (d *Distributor) UnassignSoul(soulID string)
UnassignSoul removes a soul assignment
func (*Distributor) UnregisterNode ¶ added in v0.1.0
func (d *Distributor) UnregisterNode(nodeID string)
UnregisterNode removes a node and triggers failover
func (*Distributor) UpdateNodeLoad ¶ added in v0.1.0
func (d *Distributor) UpdateNodeLoad(nodeID string, cpu, memory float64, soulCount int)
UpdateNodeLoad updates load information for a node
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles cluster coordination
func NewManager ¶
NewManager creates a new cluster manager
func (*Manager) GetStatus ¶
func (m *Manager) GetStatus() *ClusterStatus
GetStatus returns cluster status information
func (*Manager) IsClustered ¶
IsClustered returns true if cluster mode is enabled