Crates.io | roundrobin |
lib.rs | roundrobin |
version | 0.1.1 |
source | src |
created_at | 2019-12-04 15:16:47.845718 |
updated_at | 2019-12-09 15:18:15.332084 |
description | A simple roundrobin implementation. |
homepage | https://crates.io/crates/roundrobin |
repository | https://github.com/shonenada/roundrobin-rs |
max_upload_size | |
id | 186410 |
size | 11,618 |
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"
use roundrobin::wrr::*;
fn main() {
let url01 = "http://localhost:8081".to_string();
let url02 = "http://localhost:8082".to_string();
let server01 = Server::new(url01.clone(), 1);
let mut rr = WeightedRoundRobinBalancer::new();
rr.insert_server(server01); // default weight 1
rr.insert_url(url02.clone(), 2);
println!("Server: {}", rr.next().unwrap());
}
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)