queue

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package queue implements a concurrent queue of reconcile items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Item returns a value from the queue.

Once the Value is processed, either Release() or Requeue() must be called.

func (*Item[K, V]) Get added in v1.11.0

func (item *Item[K, V]) Get() (K, V)

Get returns the key and value from the queue.

func (*Item[K, V]) Key added in v1.11.0

func (item *Item[K, V]) Key() K

Key returns just the key.

func (*Item[K, V]) Release

func (item *Item[K, V]) Release()

Release removes the Item from the queue.

Calling Release after Requeue is a no-op.

func (*Item[K, V]) Requeue

func (item *Item[K, V]) Requeue(requeueAfter time.Time)

Requeue puts the Item back to the queue with specified backoff.

type Queue

type Queue[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Queue is a concurrent queue of items to be reconciled.

Queue is goroutine safe, Run() method should be called in a separate goroutine for the queue to operate.

func NewQueue

func NewQueue[K comparable, V any]() *Queue[K, V]

NewQueue creates a new queue.

func (*Queue[K, V]) Get

func (queue *Queue[K, V]) Get() <-chan *Item[K, V]

Get should never return same Item until this Item is released.

func (*Queue[K, V]) Len

func (queue *Queue[K, V]) Len() int64

Len returns the number of items in the queue.

Len includes items which are on-hold.

func (*Queue[K, V]) Put

func (queue *Queue[K, V]) Put(key K, value V)

Put should never block.

Put should deduplicate Items, i.e. if the same Item is Put twice, only one Item should be returned by Get.

func (*Queue[K, V]) Run

func (queue *Queue[K, V]) Run(ctx context.Context)

Run should be called in a goroutine.

Run returns when the context is canceled. You can call Run only once.

Jump to

Keyboard shortcuts

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