https://github.com/cipherself/conshash
conshash is a library to do consistent hashing in Rust.
https://github.com/cipherself/conshash
consistent-hashing distributed-systems rust
Last synced: 4 months ago
JSON representation
conshash is a library to do consistent hashing in Rust.
- Host: GitHub
- URL: https://github.com/cipherself/conshash
- Owner: cipherself
- License: mit
- Created: 2015-06-08T15:43:07.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-04-18T10:15:49.000Z (about 5 years ago)
- Last Synced: 2025-10-06T12:48:43.816Z (7 months ago)
- Topics: consistent-hashing, distributed-systems, rust
- Language: Rust
- Homepage: https://crates.io/crates/conshash
- Size: 8.79 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# conshash
[](https://travis-ci.org/muattiyah/conshash)
A library to do consistent hashing in Rust.
## Crate
Get the crate at [conshash](https://crates.io/crates/conshash)
## Example
```Rust
extern crate conshash;
#[derive(Clone , Debug)]
struct TestNode {
host_name: &'static str,
ip_address: &'static str,
port: u32,
}
impl ToString for TestNode {
fn to_string(&self) -> String {
format!("{}{}", self.ip_address.to_string(), self.port.to_string())
}
}
let mut hash_ring = Ring::new(5);
let test_node = TestNode{host_name: "Skynet", ip_address: "192.168.1.1", port: 42};
hash_ring.add_node(&test_node);
hash_ring.remove_node(&test_node);
hash_ring.add_node(&test_node);
let x = hash_ring.get_node(hash(&format!("{}{}", test_node.to_string(), 0.to_string())));
// x is the node in the form of an Option where T: Clone + ToString + Debug
```
## License
[MIT](./LICENSE)