rotor

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package rotor provides a thread-safe, generic type for rotating through a slice of items in a round-robin fashion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rotor

type Rotor[E any] interface {
	// Next returns the next item in the rotation.
	// This method is safe for concurrent use by multiple goroutines.
	Next() E
}

Rotor provides thread-safe round-robin access to a slice of items. It must be initialized with the New function.

func New

func New[E any](items []E) Rotor[E]

New creates a new Rotor. It makes a defensive copy of the provided items slice to ensure immutability. This function panics if the items slice is empty.

Jump to

Keyboard shortcuts

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