Mesh.Cluster.Rebalancing (Mesh v0.1.4)
View SourceCoordinates rebalancing when capabilities are registered or removed.
When a node registers capabilities, this module ensures a coordinated rebalancing process across all nodes with the same capabilities:
- Enter rebalancing mode (pause new actor creation)
- Gracefully stop actors for affected capabilities
- Synchronize shards across all participating nodes
- Exit rebalancing mode (resume normal operation)
This prevents race conditions and ensures consistent actor placement during topology changes.
Summary
Functions
Returns a specification to start this module under a supervisor.
Initiates coordinated rebalancing for the given capabilities.
Returns current rebalancing mode: :active or :rebalancing
Checks if a capability is currently rebalancing.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Initiates coordinated rebalancing for the given capabilities.
This function will:
- Calculate current shard ownership (before registration)
- Register capabilities (changes topology)
- Calculate new shard ownership (after registration)
- Put affected nodes into rebalancing mode
- Stop only actors on shards that changed ownership
- Sync shards
- Resume normal operation
Returns :ok or {:error, reason}
Returns current rebalancing mode: :active or :rebalancing
Checks if a capability is currently rebalancing.