A weighted roundrobin implementation in Rustlang.
roundrobin-rs is available on crates.io.
Add the following dependency to your Cargo.toml:
[dependencies]
roundrobin = "0.1.0"
```rust use roundrobin::wrr::*;
fn main() { let url01 = "http://localhost:8081".tostring(); let url02 = "http://localhost:8082".tostring(); let server01 = Server::new(url01.clone(), 1); let mut rr = WeightedRoundRobinBalancer::new(); rr.insertserver(server01); // default weight 1 rr.inserturl(url02.clone(), 2); println!("Server: {}", rr.next().unwrap()); } ```
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)