Thanks to visit codestin.com
Credit goes to lib.rs

#hash-ring #replication #consistent-hashing #coordinator #in-memory-cluster

hashring_coordinator

Calculates hash ranges to help coordinate a hashring (using consistent hashing) for storing and finding keys, and replicating keys between nodes if the cluster changes (add, remove nodes) or between two clusters (for example during deployments)

6 releases

Uses new Rust 2024

0.3.3 Sep 27, 2025
0.3.2 Sep 26, 2025
0.2.0 Sep 2, 2025
0.1.0 Sep 1, 2025

#846 in Algorithms

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

351 downloads per month

MIT license

46KB
819 lines

hashring_coordinator

github crates.io docs.rs build status audit status

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

Features

  • derive: to allow serde (de)serialization of struct Replicas

Example

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 functions
  • cluster.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

Dependencies

~215KB