()
| 93 | } |
| 94 | |
| 95 | fn main() { |
| 96 | let replica = 3; |
| 97 | let mut ring = Ring::with_capacity(replica); |
| 98 | |
| 99 | let node = Node{ |
| 100 | host: "localhost", |
| 101 | ip: "127.0.0.1", |
| 102 | port: 23, |
| 103 | }; |
| 104 | ring.add(&node); |
| 105 | |
| 106 | for i in 0..replica { |
| 107 | let key = hash(&format!("{}{}", node.to_string(), i.to_string())); |
| 108 | let res = ring.get(key); |
| 109 | assert_eq!(node.host, res.unwrap().host); |
| 110 | } |
| 111 | |
| 112 | println!("{:?}", &node); |
| 113 | ring.remove(&node); |
| 114 | } |