Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# weighted-roundrobin

Implementation of weighted round robin algorithm.

## SYNOPSIS

```go
package main

import (
"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]
}
```