Help us shape the future of Go! Take the 2026 Go Developer Survey

roundrobin

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 2 Imported by: 1

README

roundrobin

roundrobin with configurable rotating strategies - inspired by https://github.com/hlts2/round-robin

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	RotateAmount: 1,
}
View Source
var ErrNoItems = errors.New("no items")

ErrNoItems specified for the algorithm

Functions

This section is empty.

Types

type Item

type Item struct {
	Stats Stats
	// contains filtered or unexported fields
}

func (Item) String

func (i Item) String() string

type Options

type Options struct {
	RotateAmount int32
}

type RoundRobin

type RoundRobin struct {
	Options Options
	// contains filtered or unexported fields
}

RoundRobin iterates over the items in a round robin fashion

func New

func New(items ...string) (*RoundRobin, error)

New returns a new RoundRobin structure

func NewWithOptions

func NewWithOptions(options Options, items ...string) (*RoundRobin, error)

New returns a new RoundRobin structure with custom options

func (*RoundRobin) Add

func (r *RoundRobin) Add(items ...string)

Next returns next item

func (*RoundRobin) Next

func (r *RoundRobin) Next() Item

Next returns next item

type Stats

type Stats struct {
	Count int32
}

func (*Stats) Inc

func (s *Stats) Inc(value int32)

func (*Stats) Reset

func (s *Stats) Reset()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL