Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

conshash

Build Status

A library to do consistent hashing in Rust.

Crate

Get the crate at conshash

Example

externcrate conshash;#[derive(Clone,Debug)]structTestNode{host_name:&'staticstr,ip_address:&'staticstr,port:u32,}implToStringforTestNode{fnto_string(&self) -> String{format!("{}{}",self.ip_address.to_string(),self.port.to_string())}}letmut 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<T> where T: Clone + ToString + Debug

License

MIT

About

conshash is a library to do consistent hashing in Rust.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages