pub struct Ring { /* private fields */ }
Implementations§
Source§impl Ring
impl Ring
Sourcepub fn new(config: Config) -> Self
pub fn new(config: Config) -> Self
Examples found in repository?
examples/ring.rs (line 4)
3fn main() {
4 let mut r = Ring::new(Config::default());
5
6 r.add("1.1.1.1");
7 r.add("2.2.2.2");
8 r.add("3.3.3.3");
9
10 println!("{:?}", r.get("1.1.1.1"));
11 println!("{:?}", r.get("8.8.8.8"));
12 println!("{:?}", r.get("/foo"));
13 println!("{:?}", r.get("/bar"));
14}
pub fn replication_factor(&self) -> u64
Sourcepub fn add(&mut self, hostname: &str)
pub fn add(&mut self, hostname: &str)
Adds a new host to the ring. If the host already added, ignore.
Examples found in repository?
examples/ring.rs (line 6)
3fn main() {
4 let mut r = Ring::new(Config::default());
5
6 r.add("1.1.1.1");
7 r.add("2.2.2.2");
8 r.add("3.3.3.3");
9
10 println!("{:?}", r.get("1.1.1.1"));
11 println!("{:?}", r.get("8.8.8.8"));
12 println!("{:?}", r.get("/foo"));
13 println!("{:?}", r.get("/bar"));
14}
Sourcepub fn get(&mut self, key: &str) -> Option<String>
pub fn get(&mut self, key: &str) -> Option<String>
Locates a host for the key.
Examples found in repository?
examples/ring.rs (line 10)
3fn main() {
4 let mut r = Ring::new(Config::default());
5
6 r.add("1.1.1.1");
7 r.add("2.2.2.2");
8 r.add("3.3.3.3");
9
10 println!("{:?}", r.get("1.1.1.1"));
11 println!("{:?}", r.get("8.8.8.8"));
12 println!("{:?}", r.get("/foo"));
13 println!("{:?}", r.get("/bar"));
14}
Sourcepub fn get_least(&mut self, key: &str) -> Option<String>
pub fn get_least(&mut self, key: &str) -> Option<String>
Picks the least load host for the key.
Trait Implementations§
Auto Trait Implementations§
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