queue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ErrRetryForever = -1
	ErrRetryNone    = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleResult

type HandleResult struct {
	// RequeueRateLimited re-enqueue the object after the rate limiter says it's ok. Defaults to false.
	RequeueRateLimited bool

	// RequeueImmediately tells the Queue to requeue the object immediately. Defaults to false.
	RequeueImmediately bool

	// RequeueAfter tells the Queue to re-enqueue the object after the Duration if it is greater than 0.
	RequeueAfter time.Duration

	// MaxRequeueTimes tells the Queue the limit count of requeueing object. Defaults to 1.
	// If you want to requeue forever, please use set it to MaxErrRetryForever
	MaxRequeueTimes int
}

type Handler

type Handler func(obj interface{}) (HandleResult, error)

type Queue

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

Queue is a wrapper of kubernetes workqueue to do asynchronous work easily. It requires a Handler and an optional key function. After starting the Queue, you can call the Enqueque function to enqueue items. Queue will get key from the items by keyFunc, and add the key to the rate limit workqueue. The worker will be invoked to call the Handler.

func NewQueue

func NewQueue(handler Handler) *Queue

NewQueue returns a new Queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(obj interface{})

Enqueue wraps queue.Add

func (*Queue) EnqueueAfter

func (q *Queue) EnqueueAfter(obj interface{}, after time.Duration)

EnqueueAfter wraps queue.AddAfter. It adds an item to the workqueue after the indicated duration has passed

func (*Queue) EnqueueRateLimited

func (q *Queue) EnqueueRateLimited(obj interface{})

EnqueueRateLimited wraps queue.AddRateLimited. It adds an item to the workqueue after the rate limiter says its ok

func (*Queue) IsShuttingDown

func (q *Queue) IsShuttingDown() bool

IsShuttingDown returns if the method Shutdown was invoked

func (*Queue) Len

func (q *Queue) Len() int

Len returns the unprocessed item length

func (*Queue) Queue

Queue returns the rate limit work queue

func (*Queue) Run

func (q *Queue) Run(workers int)

Run starts n workers to sync

func (*Queue) SetMaxErrRetries

func (q *Queue) SetMaxErrRetries(max int) *Queue

SetMaxRetries sets the max retry times of the queue

func (*Queue) ShutDown

func (q *Queue) ShutDown()

ShutDown shuts down the work queue and waits for the worker to ACK

Jump to

Keyboard shortcuts

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