Skip to content

A Go (Golang) high-quality, concurrency-safe implementation of Round Robin(RR) algorithm for managing and cycling through a collection of items.

License

Notifications You must be signed in to change notification settings

hueristiq/hq-go-roundrobin

Repository files navigation

hq-go-roundrobin

made with go go report card license maintenance open issues closed issues contribution

hq-go-roundrobin is a Go (Golang) high-quality, concurrency-safe implementation of Round Robin(RR) algorithm for managing and cycling through a collection of items.

Resources

Features

  • Ensures safe concurrent access and modification of the round-robin queue.
  • Prevents duplicate items in the queue, maintaining the integrity of the rotation.
  • Customizable configuration to define how often the rotation should move to the next item.
  • Provides a straightforward API for adding items and retrieving the next item in the round-robin sequence.

Installation

To install hq-go-roundrobin, run:

go get -v -u github.com/hueristiq/hq-go-roundrobin

Make sure your Go environment is set up properly (Go 1.x or later is recommended).

Usage

Here's a simple example to get you started with hq-go-roundrobin:

package main

import (
	"fmt"
	
	hqgoroundrobin "github.com/hueristiq/hq-go-roundrobin"
)

func main() {
	// Create a new round-robin instance with default options and initial items.
	rr, err := hqgoroundrobin.New("item1", "item2", "item3")
	if err != nil {
		panic(err)
	}

	// Add more items if needed
	rr.Add("item4", "item5")

	// Retrieve and process items in a round-robin fashion
	for i := 0; i < 10; i++ {
		item := rr.Next()
		fmt.Printf("Serving: %s\n", item.Value())
	}

	/*
		Output:
		item1
		item2
		item3
		item4
		item5
		item1
		item2
		item3
		item4
		item5
	*/

}

Contributing

Contributions are welcome and encouraged! Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.

A big thank you to all the contributors for your ongoing support!

contributors

Licensing

This package is licensed under the MIT license. You are free to use, modify, and distribute it, as long as you follow the terms of the license. You can find the full license text in the repository - Full MIT license text.

About

A Go (Golang) high-quality, concurrency-safe implementation of Round Robin(RR) algorithm for managing and cycling through a collection of items.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •