Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vvatanabe/weighted-roundrobin
Implementation of weighted round robin algorithm
https://github.com/vvatanabe/weighted-roundrobin
golang weighted-roundrobin
Last synced: 24 days ago
JSON representation
Implementation of weighted round robin algorithm
- Host: GitHub
- URL: https://github.com/vvatanabe/weighted-roundrobin
- Owner: vvatanabe
- License: mit
- Created: 2020-01-21T18:37:01.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-21T19:10:49.000Z (almost 5 years ago)
- Last Synced: 2024-06-21T02:16:05.021Z (5 months ago)
- Topics: golang, weighted-roundrobin
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# weighted-roundrobin
Implementation of weighted round robin algorithm.
## SYNOPSIS
```go
package mainimport (
"fmt""github.com/vvatanabe/weighted-roundrobin"
)func main() {
rr := weighted.New([]*weighted.Node{
{
Value: "apple",
Weight: 2,
},
{
Value: "banana",
Weight: 4,
},
{
Value: "grape",
Weight: 4,
},
{
Value: "orange",
Weight: 18,
},
})result := make(map[string]uint64)
for i := 0; i < 100; i++ {
n := rr.GetNode()
name := n.Value.(string)
result[name] = result[name] + 1
}fmt.Println(result)
// map[apple:7 banana:14 grape:14 orange:65]
}
```