Mesh.Shards.ShardRouter (Mesh v0.1.4)
View SourceRoutes processes to nodes based on hashing (hash ring).
The hashing strategy is configurable via application config:
config :mesh, :hash_strategy, Mesh.Shards.HashStrategy.EventualConsistencyThe default strategy uses modulo-based distribution for deterministic routing.
Summary
Functions
Determines which node owns a given shard for a specific capability.
Computes the shard number for a given actor ID.
Functions
@spec owner_node(non_neg_integer(), atom()) :: {:ok, node()} | {:error, :no_nodes}
Determines which node owns a given shard for a specific capability.
Returns {:ok, node} if nodes are available for the capability,
or {:error, :no_nodes} if no nodes support the capability.
The specific distribution algorithm is determined by the configured hash strategy.
@spec shard_for(String.t()) :: non_neg_integer()
Computes the shard number for a given actor ID.