queue

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 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[T comparable] 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[T]) Release

func (item *Item[T]) Release()

Release removes the Item from the queue.

Calling Release after Requeue is a no-op.

func (*Item[T]) Requeue

func (item *Item[T]) Requeue(requeueAfter time.Time)

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

func (*Item[T]) Value

func (item *Item[T]) Value() T

Value returns the value from the queue.

type Queue

type Queue[T comparable] 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[T comparable]() *Queue[T]

NewQueue creates a new queue.

func (*Queue[T]) Get

func (queue *Queue[T]) Get() <-chan *Item[T]

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

func (*Queue[T]) Len

func (queue *Queue[T]) Len() int64

Len returns the number of items in the queue.

Len includes items which are on-hold.

func (*Queue[T]) Put

func (queue *Queue[T]) Put(value T)

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[T]) Run

func (queue *Queue[T]) 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