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