swarm v3.4.0 Swarm.Distribution.Strategy behaviour
This module implements the interface for custom distribution strategies.
The default strategy used by Swarm is a consistent hash ring implemented
via the libring
library.
Custom strategies are expected to return a datastructure or pid which will be passed along to any functions which need to manipulate the current distribution state. This can be either a plain datastructure (as is the case with the libring-based strategy), or a pid which your strategy module then uses to call a process in your own supervision tree.
For efficiency reasons, it is highly recommended to use plain datastructures rather than a process for storing the distribution state, because it has the potential to become a bottleneck otherwise, however this is really up to the needs of your situation, just know that you can go either way.
Link to this section Summary
Functions
Adds a node to the state of the current distribution strategy
Adds a node to the state of the current distribution strategy, and give it a specific weighting relative to other nodes
Adds a list of nodes to the state of the current distribution strategy. The node list can be composed of both node names (atoms) or tuples containing a node name and a weight for that node
Maps a key to a specific node via the current distribution strategy
Removes a node from the state of the current distribution strategy
Link to this section Types
Link to this section Functions
Adds a node to the state of the current distribution strategy.
Adds a node to the state of the current distribution strategy, and give it a specific weighting relative to other nodes.
Adds a list of nodes to the state of the current distribution strategy. The node list can be composed of both node names (atoms) or tuples containing a node name and a weight for that node.
Maps a key to a specific node via the current distribution strategy.
Removes a node from the state of the current distribution strategy.