https://github.com/projectdiscovery/roundrobin
roundrobin with configurable rotating strategies
https://github.com/projectdiscovery/roundrobin
lib
Last synced: over 1 year ago
JSON representation
roundrobin with configurable rotating strategies
- Host: GitHub
- URL: https://github.com/projectdiscovery/roundrobin
- Owner: projectdiscovery
- License: mit
- Created: 2021-10-18T14:44:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-21T00:49:30.000Z (almost 3 years ago)
- Last Synced: 2025-04-02T21:39:01.452Z (over 1 year ago)
- Topics: lib
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 14
- Watchers: 13
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# roundrobin
[](LICENSE.md)

[](https://github.com/projectdiscovery/roundrobin/releases/)
[](https://github.com/projectdiscovery/roundrobin/actions/workflows/build-test.yml)
[](https://pkg.go.dev/github.com/projectdiscovery/roundrobin)
A Golang Implementation of RoundRobin Algorithm with configurable rotating strategies.
# Features
- Configurable Rotating Strategies
- Track Stats of Each Item
- Generic Implementation
- Concurrency Safe
## Example
An Example showing usage of roundrobin as a library is specified below:
```go
package main
import (
"fmt"
"github.com/projectdiscovery/roundrobin"
)
func main() {
ips := []string{
"192.168.29.58",
"192.168.29.1",
"192.168.29.92",
}
// create new roundrobin iterator
rb, err := roundrobin.New(ips...)
if err != nil {
panic(err)
}
// rb.Add adds given item to sequence
rb.Add("192.168.29.86")
for i := 0; i < 10; i++ {
// rb.Next returns next item in roundrobin fashion
val := rb.Next().String()
fmt.Println(val)
}
/*
Output:
192.168.29.58
192.168.29.1
192.168.29.92
192.168.29.86
192.168.29.58
192.168.29.1
192.168.29.92
192.168.29.86
192.168.29.58
192.168.29.1
*/
}
```
For more details refer [GoDoc](https://pkg.go.dev/github.com/projectdiscovery/roundrobin) .
## Acknowledgement
Inspired by `https://github.com/hlts2/round-robin`