queue

package
v1.18.3-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShutdown = errors.New("object queue shutting down")

ErrShutdown is returned by `ObjectQueue.Get` if the queue is shut down before an object is available/added.

Functions

func MarkDeleted

func MarkDeleted(ctx context.Context, obj client.Object) client.Object

MarkDeleted marks the given Object as having been deleted from the cluster. On receiving a Deleted event, Watchers should call this *first* and then pass the returned Object to Add().

func WasDeleted

func WasDeleted(ctx context.Context, obj client.Object) bool

WasDeleted returns true if the given Object was marked as having been deleted from the cluster.

Types

type Deleted added in v1.15.1

type Deleted struct {
	client.Object
}

Deleted wraps an Object that has be deleted

func (*Deleted) DeepCopyObject added in v1.15.1

func (d *Deleted) DeepCopyObject() runtime.Object

DeepCopyObject implements client.Object.

This ensures when we deepcopy a deleted object, we retain that it is deleted.

type GVKNN

type GVKNN struct {
	core.ID
	Version string
}

GVKNN adds Version to core.ID to make it suitable for getting an object from a cluster into an *unstructured.Unstructured.

func GVKNNOf

func GVKNNOf(obj client.Object) GVKNN

GVKNNOf converts an Object to its GVKNN.

func (GVKNN) GroupVersionKind

func (gvknn GVKNN) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GVK contained in this GVKNN.

type Interface

type Interface interface {
	Add(obj client.Object)
	Get(context.Context) (client.Object, error)
	Done(obj client.Object)
	Forget(obj client.Object)
	Retry(obj client.Object)
	ShutDown()
}

Interface is the methods ObjectQueue satisfies. See ObjectQueue for method definitions.

type ObjectQueue

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

ObjectQueue is a wrapper around a workqueue.Interface for use with declared resources. It deduplicates work items by their GVKNN. NOTE: This was originally designed to wrap a DelayingInterface, but we have had to copy a lot of that logic here. At some point it may make sense to remove the underlying workqueue.Interface and just consolidate copied logic here.

func New

func New(name string) *ObjectQueue

New creates a new work queue for use in signalling objects that may need remediation.

func (*ObjectQueue) Add

func (q *ObjectQueue) Add(obj client.Object)

Add marks the object as needing processing unless the object is already in the queue AND the existing object is more current than the new one.

func (*ObjectQueue) Done

func (q *ObjectQueue) Done(obj client.Object)

Done marks item as done processing, and if it has been marked as dirty again while it was being processed, it will be re-added to the queue for re-processing.

func (*ObjectQueue) Forget

func (q *ObjectQueue) Forget(obj client.Object)

Forget is a convenience method that allows callers to directly tell the RateLimitingInterface to forget a specific client.Object.

func (*ObjectQueue) Get

func (q *ObjectQueue) Get(ctx context.Context) (client.Object, error)

Get blocks until one of the following conditions: A) An item is ready to be processed B) The context is cancelled or times out C) The queue is shutting down

Returns the next item to process, and either a `context.Canceled`, `context.DeadlineExceeded`, or `queue.ErrShutdown`.

If the queue has been shut down the caller should end their goroutine.

You must call Done with item when you have finished processing it or else the item will never be processed again.

func (*ObjectQueue) Len

func (q *ObjectQueue) Len() int

Len returns the length of the underlying queue.

func (*ObjectQueue) Retry

func (q *ObjectQueue) Retry(obj client.Object)

Retry schedules the object to be requeued using the rate limiter.

func (*ObjectQueue) ShutDown

func (q *ObjectQueue) ShutDown()

ShutDown shuts down the object queue.

func (*ObjectQueue) ShuttingDown

func (q *ObjectQueue) ShuttingDown() bool

ShuttingDown returns true if the object queue is shutting down.

Jump to

Keyboard shortcuts

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