taskqueue

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package taskqueue provides a task queue for syncing objects in parallel.

Index

Constants

This section is empty.

Variables

View Source
var (
	// KeyFunc is the default key function for the task queue.
	// It uses the cache.DeletionHandlingMetaNamespaceKeyFunc, which is the same as the default
	// key function for the k8s workqueue.
	KeyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc
)

Functions

This section is empty.

Types

type PeriodicTaskQueueWithMultipleWorkers

type PeriodicTaskQueueWithMultipleWorkers struct {
	// contains filtered or unexported fields
}

PeriodicTaskQueueWithMultipleWorkers invokes the given sync function for every work item inserted, while running n parallel worker routines. If the sync() function results in an error, the item is put on the work queue after a rate-limit.

func NewPeriodicTaskQueueWithMultipleWorkers

func NewPeriodicTaskQueueWithMultipleWorkers(name, resource string, numWorkers int, syncFn func(context.Context, string) error) *PeriodicTaskQueueWithMultipleWorkers

NewPeriodicTaskQueueWithMultipleWorkers creates a new task queue with the default rate limiter and the given number of worker goroutines.

func (*PeriodicTaskQueueWithMultipleWorkers) Enqueue

func (t *PeriodicTaskQueueWithMultipleWorkers) Enqueue(objs ...any)

Enqueue adds one or more keys to the work queue.

func (*PeriodicTaskQueueWithMultipleWorkers) Len

Len returns the length of the queue.

func (*PeriodicTaskQueueWithMultipleWorkers) NumRequeues

func (t *PeriodicTaskQueueWithMultipleWorkers) NumRequeues(obj any) int

NumRequeues returns the number of times the given item was requeued.

func (*PeriodicTaskQueueWithMultipleWorkers) Run

Run spawns off n parallel worker routines and returns immediately.

func (*PeriodicTaskQueueWithMultipleWorkers) Shutdown

Shutdown shuts down the work queue and waits for all the workers to ACK

func (*PeriodicTaskQueueWithMultipleWorkers) ShuttingDown

func (t *PeriodicTaskQueueWithMultipleWorkers) ShuttingDown() bool

ShuttingDown returns true if the queue is shutting down.

type TaskQueue

type TaskQueue interface {
	// Run starts the task queue.
	Run()
	// Enqueue adds one or more keys to the work queue.
	Enqueue(objs ...any)
	// Shutdown shuts down the work queue and waits for all the workers to ACK.
	Shutdown()
	// Len returns the length of the queue.
	Len() int
	// NumRequeues returns the number of times the given item was requeued.
	NumRequeues(obj any) int
	// ShuttingDown returns true if the queue is shutting down.
	ShuttingDown() bool
}

TaskQueue is a rate limited operation queue.

Jump to

Keyboard shortcuts

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