A minimal implementation of consistent hashing.
Clients can use the HashRing struct to add consistent hashing to their
applications.
- You can add and remove nodes to a HashRing.
- Find all nodes that (should) store a given key.
- Return all hash ranges within the HashRing to easily detect nodes and their responsibilities (containing replica nodes as well)
- Compare two HashRing clusters to receive replication instructions between both clusters (for each node, list hash ranges and target nodes to find keys that need to be replicated)
This implemementation is based on the original source: https://github.com/jeromefroe/hashring-rs
- derive: to allow serde (de)serialization of
struct Replicas
Take a look at the examples directory for further details like replication during deployments or after adding/removing nodes from the cluster
simple.rs- gives a brief overview of the main functionscluster.rs- implements a cluster and shows how to rebalance the cluster if a node as added or removed and how to synchronize all values to a completely new cluster