syncqueue

package
v0.0.0-...-43b7830 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PassthroughKeyFunc

func PassthroughKeyFunc(obj interface{}) (interface{}, error)

PassthroughKeyFunc is a keyFunc which returns the original obj

Types

type KeyFunc

type KeyFunc func(obj interface{}) (interface{}, error)

KeyFunc describes a function that generates a key from a object

type Result

type Result struct {
	// Requeue tells the Queue to requeue the object. Defaults to false.
	Requeue bool

	// RequeueAfter if greater than 0, tells the Queue to requeue the object after the Duration.
	// Implies that Requeue is true, there is no need to set Requeue to true at the same time as RequeueAfter.
	RequeueAfter time.Duration

	// MaxRequeueTimes tells the Queue the limit count of requeueing object. Defaults to 0.
	// It only take effect when Requeue is true or RequeueAfter is greater than 0.
	MaxRequeueTimes int
}

Result contains the result of a Reconciler invocation.

type SyncHandler

type SyncHandler func(obj interface{}) (Result, error)

SyncHandler describes the function which will be called for each item in the queue

if the sync handler returns an *ErrRetryAfter error, the queue will put obj back and retry after a period of time

type SyncQueue

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

SyncQueue is a helper for creating a kubernetes controller easily It requires a syncHandler and an optional key function. After running the syncQueue, you can call it's Enqueque function to enqueue items. SyncQueue 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 syncHandler.

func NewCustomSyncQueue

func NewCustomSyncQueue(gvk schema.GroupVersionKind, syncHandler SyncHandler, keyFunc KeyFunc) *SyncQueue

NewCustomSyncQueue returns a new SyncQueue using custom keyFunc

func NewPassthroughSyncQueue

func NewPassthroughSyncQueue(gvk schema.GroupVersionKind, syncHandler SyncHandler) *SyncQueue

NewPassthroughSyncQueue returns a new SyncQueue with PassthroughKeyFunc

func NewSyncQueue

func NewSyncQueue(gvk schema.GroupVersionKind, syncHandler SyncHandler) *SyncQueue

NewSyncQueue returns a new SyncQueue, enqueue key of obj using default keyFunc

func (*SyncQueue) Dequeue

func (sq *SyncQueue) Dequeue(obj interface{})

Dequeue calls the RateLimitingInterface.Froget and Done to stop tracking the item

func (*SyncQueue) Enqueue

func (sq *SyncQueue) Enqueue(obj interface{})

Enqueue wraps queue.Add

func (*SyncQueue) EnqueueAfter

func (sq *SyncQueue) EnqueueAfter(obj interface{}, after time.Duration)

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

func (*SyncQueue) EnqueueRateLimited

func (sq *SyncQueue) EnqueueRateLimited(obj interface{})

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

func (*SyncQueue) FilteringResourceEventHandler

func (sq *SyncQueue) FilteringResourceEventHandler(scheme *runtime.Scheme, filter func(obj interface{}) bool) cache.ResourceEventHandler

func (*SyncQueue) IsShuttingDown

func (sq *SyncQueue) IsShuttingDown() bool

IsShuttingDown returns if the method Shutdown was invoked

func (*SyncQueue) Queue

Queue returns the rate limit work queue

func (*SyncQueue) ResourceEventHandler

func (sq *SyncQueue) ResourceEventHandler(scheme *runtime.Scheme) cache.ResourceEventHandler

func (*SyncQueue) Run

func (sq *SyncQueue) Run(workers int)

Run starts n workers to sync

func (*SyncQueue) SetMaxErrRetries

func (sq *SyncQueue) SetMaxErrRetries(max int)

SetMaxRetries sets the max retry times of the queue

func (*SyncQueue) ShutDown

func (sq *SyncQueue) 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