workqueue

package
v0.0.0-...-0f8ae5d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

package workqueue is a amended copy of k8s' workqueue implementation

Changes made: - workqueue.go - Added MaxSize field to default workqueue. - workqueue.go - Added bool return value whether value was added. - workqueue.go - Added Identifier interface to allow items in workqueue to deviate from the associated ID. - workqueue.go - Added Replace field to allow subsequent Adds of the same ID to simply replace the value. - delaying_queue.go - added non-blocking TryAddAfter. - all - Replaced t and set types with interface{} and map[interface{}]interface{}

upstream source: https://github.com/kubernetes/client-go/tree/master/util/workqueue

Index

Constants

View Source
const (
	DefaultMaxSize = 10000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayingInterface

type DelayingInterface interface {
	Interface
	// AddAfter adds an item to the workqueue after the indicated duration has passed
	AddAfter(item interface{}, duration time.Duration)

	TryAddAfter(item interface{}, duration time.Duration) bool
}

DelayingInterface is an Interface that can Add an item at a later time. This makes it easier to requeue items after failures without ending up in a hot-loop.

func NewDelayingQueue

func NewDelayingQueue(maxSize int) DelayingInterface

NewDelayingQueue constructs a new workqueue with delayed queuing ability

func NewNamedDelayingQueue

func NewNamedDelayingQueue(name string) DelayingInterface

type Identifier

type Identifier interface {
	ID() interface{}
}

type Interface

type Interface interface {
	Add(item interface{}) (accepted bool)
	Len() int
	Get() (item interface{}, shutdown bool)
	Done(item interface{})
	ShutDown()
	ShuttingDown() bool
}

type Type

type Type struct {
	MaxSize int
	Replace bool
	// contains filtered or unexported fields
}

Type is a work queue (see the package comment).

func New

func New() *Type

New constructs a new work queue (see the package comment).

func NewNamed

func NewNamed(maxSize int, _ string) *Type

func NewWorkQueue

func NewWorkQueue(maxSize int, replace bool) *Type

func (*Type) Add

func (q *Type) Add(item interface{}) (accepted bool)

Add marks item as needing processing.

func (*Type) Done

func (q *Type) Done(item interface{})

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 (*Type) Get

func (q *Type) Get() (item interface{}, shutdown bool)

Get blocks until it can return an item to be processed. If shutdown = true, the caller should end their goroutine. You must call Done with item when you have finished processing it.

func (*Type) Len

func (q *Type) Len() int

Len returns the current queue length, for informational purposes only. You shouldn't e.g. gate a call to Add() or Get() on Len() being a particular value, that can't be synchronized properly.

func (*Type) ShutDown

func (q *Type) ShutDown()

ShutDown will cause q to ignore all new items added to it. As soon as the worker goroutines have drained the existing items in the queue, they will be instructed to exit.

func (*Type) ShuttingDown

func (q *Type) ShuttingDown() bool

Jump to

Keyboard shortcuts

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