priorityqueue

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOpts

type AddOpts struct {
	After       time.Duration
	RateLimited bool
	// Priority is the priority of the item. Higher values
	// indicate higher priority.
	// Defaults to zero if unset.
	Priority *int
}

AddOpts describes the options for adding items to the queue.

type Opt

type Opt[T comparable] func(*Opts[T])

Opt allows to configure a PriorityQueue.

type Opts

type Opts[T comparable] struct {
	// Ratelimiter is being used when AddRateLimited is called. Defaults to a per-item exponential backoff
	// limiter with an initial delay of five milliseconds and a max delay of 1000 seconds.
	RateLimiter    workqueue.TypedRateLimiter[T]
	MetricProvider workqueue.MetricsProvider
	Log            logr.Logger
}

Opts contains the options for a PriorityQueue.

type PriorityQueue

type PriorityQueue[T comparable] interface {
	workqueue.TypedRateLimitingInterface[T]
	AddWithOpts(o AddOpts, Items ...T)
	GetWithPriority() (item T, priority int, shutdown bool)
}

PriorityQueue is a priority queue for a controller. It internally de-duplicates all items that are added to it. It will use the max of the passed priorities and the min of possible durations.

When an item that is already enqueued at a lower priority is re-enqueued with a higher priority, it will be placed at the end among items of the new priority, in order to preserve FIFO semantics within each priority level. The effective duration (i.e. the ready time) is still computed as the minimum across all enqueues.

func New

func New[T comparable](name string, o ...Opt[T]) PriorityQueue[T]

New constructs a new PriorityQueue.

Jump to

Keyboard shortcuts

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