Struct ringhash::Consistent

source ·
pub struct Consistent { /* private fields */ }

Implementations§

source§

impl Consistent

source

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);
    }
}
source

pub fn with_number_of_replicas(self, number_of_replicas: usize) -> Self

source

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);
    }
}
source

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);
    }
}
source

pub fn set(&self, elts: Vec<impl Into<FastStr>>)

source

pub fn members(&self) -> Vec<FastStr>

source

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);
    }
}
source

pub fn get_two( &self, name: impl AsRef<str> ) -> Result<(FastStr, FastStr), Error>

source

pub fn get_n( &self, name: impl AsRef<str>, n: usize ) -> Result<Vec<FastStr>, Error>

Trait Implementations§

source§

impl Debug for Consistent

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Consistent

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.