Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yoonper/wrr
Weighted Round Robin Balancer
https://github.com/yoonper/wrr
Last synced: 8 days ago
JSON representation
Weighted Round Robin Balancer
- Host: GitHub
- URL: https://github.com/yoonper/wrr
- Owner: yoonper
- Created: 2022-06-24T09:40:52.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-24T09:42:48.000Z (over 2 years ago)
- Last Synced: 2024-06-21T10:50:31.889Z (5 months ago)
- Language: Go
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WRR
Weighted Round Robin Balancer
---
## Getting Started
```
go get -u github.com/yoonper/wrr
``````
package mainimport (
"fmt"
"github.com/yoonper/wrr"
)func main() {
b := wrr.Init()
b.Add("item1", 2)
b.Add("item2", 5)
b.Add("item3", 3)
count := make(map[string]int)
for i := 0; i < 100; i++ {
item := b.Next()
count[item]++// you can increase or decrease item weight
// b.IncWeight("item3")
// b.DecWeight("item3")
}
fmt.Println(count)
}```
---
## Reference
[ngx_http_upstream_round_robin.c](https://github.com/phusion/nginx/blob/master/src/http/ngx_http_upstream_round_robin.c)