Struct ringhash::Consistent
source · pub struct Consistent { /* private fields */ }Implementations§
source§impl Consistent
impl Consistent
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/demo.rs (line 4)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let c = Consistent::new();
c.add("cacheA");
c.add("cacheB");
c.add("cacheC");
let users = vec![
"user_mcnulty",
"user_bunk",
"user_omar",
"user_bunny",
"user_stringer",
];
println!("initial state [A, B, C]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.add("cacheD");
c.add("cacheE");
println!("with cacheD, cacheE added [A, B, C, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.remove("cacheC");
println!("with cacheC removed [A, B, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
}pub fn with_number_of_replicas(self, number_of_replicas: usize) -> Self
sourcepub fn add(&self, elt: impl Into<FastStr>)
pub fn add(&self, elt: impl Into<FastStr>)
Examples found in repository?
examples/demo.rs (line 5)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let c = Consistent::new();
c.add("cacheA");
c.add("cacheB");
c.add("cacheC");
let users = vec![
"user_mcnulty",
"user_bunk",
"user_omar",
"user_bunny",
"user_stringer",
];
println!("initial state [A, B, C]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.add("cacheD");
c.add("cacheE");
println!("with cacheD, cacheE added [A, B, C, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.remove("cacheC");
println!("with cacheC removed [A, B, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
}sourcepub fn remove(&self, elt: impl AsRef<str>)
pub fn remove(&self, elt: impl AsRef<str>)
Examples found in repository?
examples/demo.rs (line 27)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let c = Consistent::new();
c.add("cacheA");
c.add("cacheB");
c.add("cacheC");
let users = vec![
"user_mcnulty",
"user_bunk",
"user_omar",
"user_bunny",
"user_stringer",
];
println!("initial state [A, B, C]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.add("cacheD");
c.add("cacheE");
println!("with cacheD, cacheE added [A, B, C, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.remove("cacheC");
println!("with cacheC removed [A, B, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
}pub fn set(&self, elts: Vec<impl Into<FastStr>>)
pub fn members(&self) -> Vec<FastStr>
sourcepub fn get(&self, name: impl AsRef<str>) -> Result<FastStr, Error>
pub fn get(&self, name: impl AsRef<str>) -> Result<FastStr, Error>
Examples found in repository?
examples/demo.rs (line 17)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
fn main() {
let c = Consistent::new();
c.add("cacheA");
c.add("cacheB");
c.add("cacheC");
let users = vec![
"user_mcnulty",
"user_bunk",
"user_omar",
"user_bunny",
"user_stringer",
];
println!("initial state [A, B, C]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.add("cacheD");
c.add("cacheE");
println!("with cacheD, cacheE added [A, B, C, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
c.remove("cacheC");
println!("with cacheC removed [A, B, D, E]");
for u in users.iter() {
let server = c.get(u).unwrap();
println!("{} => {}", u, server);
}
}pub fn get_two( &self, name: impl AsRef<str> ) -> Result<(FastStr, FastStr), Error>
pub fn get_n( &self, name: impl AsRef<str>, n: usize ) -> Result<Vec<FastStr>, Error>
Trait Implementations§
source§impl Debug for Consistent
impl Debug for Consistent
Auto Trait Implementations§
impl !RefUnwindSafe for Consistent
impl Send for Consistent
impl Sync for Consistent
impl Unpin for Consistent
impl UnwindSafe for Consistent
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more