{"id":17955699,"url":"https://github.com/smallnest/weighted-rs","last_synced_at":"2025-03-25T02:30:55.694Z","repository":{"id":47526356,"uuid":"205375572","full_name":"smallnest/weighted-rs","owner":"smallnest","description":"A Rust library for weighted balancing algorithm","archived":false,"fork":false,"pushed_at":"2023-08-14T04:10:45.000Z","size":11,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T11:12:14.557Z","etag":null,"topics":["balancing","election","rust","weight","weighted","weighted-balancing-algorithm"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smallnest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-30T12:13:15.000Z","updated_at":"2023-08-14T04:10:50.000Z","dependencies_parsed_at":"2024-10-29T11:04:58.653Z","dependency_job_id":null,"html_url":"https://github.com/smallnest/weighted-rs","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.2857142857142857,"last_synced_commit":"177db2575f8f82c171a92d19902ae2617b634ecf"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fweighted-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fweighted-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fweighted-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallnest%2Fweighted-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallnest","download_url":"https://codeload.github.com/smallnest/weighted-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245385306,"owners_count":20606643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["balancing","election","rust","weight","weighted","weighted-balancing-algorithm"],"created_at":"2024-10-29T10:31:48.832Z","updated_at":"2025-03-25T02:30:55.423Z","avatar_url":"https://github.com/smallnest.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# weight-rs\n\n[![Build Status](https://travis-ci.org/smallnest/weighted-rs.svg?branch=master)](https://travis-ci.org/smallnest/weighted-rs)\n[![Crate](https://img.shields.io/crates/v/weighted-rs.svg)](https://crates.io/crates/weighted-rs)\n[![API](https://docs.rs/weighted-rs/badge.svg)](https://docs.rs/weighted-rs)\n\nA Rust library for weighted balancing algorithm.\n\n\nIt provides three weighted balancing (elect) algorithm.\nOne is random algorithm.\nAnother is weighted balancing algorithm used by LVS.\nThe third is smooth weighted balancing algorithm used by Nginx.\n\nThe LVS weighted round-robin scheduling is introduced at http://kb.linuxvirtualserver.org/wiki/Weighted_Round-Robin_Scheduling.\nThe Nginx smooth weighted round-robin balancing algorithm is introduced at https://github.com/phusion/nginx/commit/27e94984486058d73157038f7950a0a36ecc6e35.\nThe random algorithm is not smooth although it follows weight configuration.\n\nUsing it is simple:\n```rust\n    use weighted_rs::{SmoothWeight, Weight};\n    use std::collections::HashMap;\n\n    let mut sw: SmoothWeight\u003c\u0026str\u003e = SmoothWeight::new();\n    sw.add(\"server1\", 5);\n    sw.add(\"server2\", 2);\n    sw.add(\"server3\", 3);\n\n    for _ in 0..100 {\n        let s = sw.next().unwrap();\n        println!(\"{}\", s);\n    }\n```\n\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nweighted-rs = \"0.1.1\"\n```\n\n\n# License\n\nweighted-rs is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and\n[COPYRIGHT](COPYRIGHT) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2Fweighted-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallnest%2Fweighted-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallnest%2Fweighted-rs/lists"}