{"modulePath":"github.com/unitytech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package workqueue\n\nPackage workqueue provides a simple queue that supports the following features:\n\n  - Fair: items processed in the order in which they are added.\n  - Stingy: a single item will not be processed multiple times concurrently, and if an item is added multiple times before it can be processed, it will only be processed once.\n  - Multiple consumers and producers. In particular, it is allowed for an item to be reenqueued while it is being processed.\n  - Shutdown notifications.\n\n## Functions\n\n```go\nfunc Parallelize(workers, pieces int, doWorkPiece DoWorkPieceFunc)\n```\nParallelize is a very simple framework that allows for parallelizing N independent pieces of work.\n\nDeprecated: Use ParallelizeUntil instead.\n\n```go\nfunc ParallelizeUntil(ctx context.Context, workers, pieces int, doWorkPiece DoWorkPieceFunc)\n```\nParallelizeUntil is a framework that allows for parallelizing N independent pieces of work until done or the context is canceled.\n\n```go\nfunc SetProvider(metricsProvider MetricsProvider)\n```\nSetProvider sets the metrics provider for all subsequently created work queues. Only the first call has an effect.\n\n## Types\n\n```go\ntype BucketRateLimiter struct {\n\t*rate.Limiter\n}\n```\nBucketRateLimiter adapts a standard bucket to the workqueue ratelimiter API\n\n```go\nfunc (r *BucketRateLimiter) Forget(item interface{})\n```\n\n```go\nfunc (r *BucketRateLimiter) NumRequeues(item interface{}) int\n```\n\n```go\nfunc (r *BucketRateLimiter) When(item interface{}) time.Duration\n```\n\n```go\ntype CounterMetric interface {\n\tInc()\n}\n```\nCounterMetric represents a single numerical value that only ever goes up.\n\n```go\ntype DelayingInterface interface {\n\tInterface\n\t// AddAfter adds an item to the workqueue after the indicated duration has passed\n\tAddAfter(item interface{}, duration time.Duration)\n}\n```\nDelayingInterface 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.\n\n```go\nfunc NewDelayingQueue() DelayingInterface\n```\nNewDelayingQueue constructs a new workqueue with delayed queuing ability\n\n```go\nfunc NewNamedDelayingQueue(name string) DelayingInterface\n```\n\n```go\ntype DoWorkPieceFunc func(piece int)\n```\n\n```go\ntype GaugeMetric interface {\n\tInc()\n\tDec()\n}\n```\nGaugeMetric represents a single numerical value that can arbitrarily go up and down.\n\n```go\ntype HistogramMetric interface {\n\tObserve(float64)\n}\n```\nHistogramMetric counts individual observations.\n\n```go\ntype Interface interface {\n\tAdd(item interface{})\n\tLen() int\n\tGet() (item interface{}, shutdown bool)\n\tDone(item interface{})\n\tShutDown()\n\tShuttingDown() bool\n}\n```\n\n```go\ntype ItemExponentialFailureRateLimiter struct {\n\t// contains filtered or unexported fields\n}\n```\nItemExponentialFailureRateLimiter does a simple baseDelay\\*2^\\\u003cnum-failures\u003e limit dealing with max failures and expiration are up to the caller\n\n```go\nfunc (r *ItemExponentialFailureRateLimiter) Forget(item interface{})\n```\n\n```go\nfunc (r *ItemExponentialFailureRateLimiter) NumRequeues(item interface{}) int\n```\n\n```go\nfunc (r *ItemExponentialFailureRateLimiter) When(item interface{}) time.Duration\n```\n\n```go\ntype ItemFastSlowRateLimiter struct {\n\t// contains filtered or unexported fields\n}\n```\nItemFastSlowRateLimiter does a quick retry for a certain number of attempts, then a slow retry after that\n\n```go\nfunc (r *ItemFastSlowRateLimiter) Forget(item interface{})\n```\n\n```go\nfunc (r *ItemFastSlowRateLimiter) NumRequeues(item interface{}) int\n```\n\n```go\nfunc (r *ItemFastSlowRateLimiter) When(item interface{}) time.Duration\n```\n\n```go\ntype MaxOfRateLimiter struct {\n\t// contains filtered or unexported fields\n}\n```\nMaxOfRateLimiter calls every RateLimiter and returns the worst case response When used with a token bucket limiter, the burst could be apparently exceeded in cases where particular items were separately delayed a longer time.\n\n```go\nfunc (r *MaxOfRateLimiter) Forget(item interface{})\n```\n\n```go\nfunc (r *MaxOfRateLimiter) NumRequeues(item interface{}) int\n```\n\n```go\nfunc (r *MaxOfRateLimiter) When(item interface{}) time.Duration\n```\n\n```go\ntype MetricsProvider interface {\n\tNewDepthMetric(name string) GaugeMetric\n\tNewAddsMetric(name string) CounterMetric\n\tNewLatencyMetric(name string) HistogramMetric\n\tNewWorkDurationMetric(name string) HistogramMetric\n\tNewUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric\n\tNewLongestRunningProcessorSecondsMetric(name string) SettableGaugeMetric\n\tNewRetriesMetric(name string) CounterMetric\n\tNewDeprecatedDepthMetric(name string) GaugeMetric\n\tNewDeprecatedAddsMetric(name string) CounterMetric\n\tNewDeprecatedLatencyMetric(name string) SummaryMetric\n\tNewDeprecatedWorkDurationMetric(name string) SummaryMetric\n\tNewDeprecatedUnfinishedWorkSecondsMetric(name string) SettableGaugeMetric\n\tNewDeprecatedLongestRunningProcessorMicrosecondsMetric(name string) SettableGaugeMetric\n\tNewDeprecatedRetriesMetric(name string) CounterMetric\n}\n```\nMetricsProvider generates various metrics used by the queue.\n\n```go\ntype RateLimiter interface {\n\t// When gets an item and gets to decide how long that item should wait\n\tWhen(item interface{}) time.Duration\n\t// Forget indicates that an item is finished being retried.  Doesn't matter whether its for perm failing\n\t// or for success, we'll stop tracking it\n\tForget(item interface{})\n\t// NumRequeues returns back how many failures the item has had\n\tNumRequeues(item interface{}) int\n}\n```\n\n```go\nfunc DefaultControllerRateLimiter() RateLimiter\n```\nDefaultControllerRateLimiter is a no-arg constructor for a default rate limiter for a workqueue.  It has both overall and per-item rate limiting.  The overall is a token bucket and the per-item is exponential\n\n```go\nfunc DefaultItemBasedRateLimiter() RateLimiter\n```\n\n```go\nfunc NewItemExponentialFailureRateLimiter(baseDelay time.Duration, maxDelay time.Duration) RateLimiter\n```\n\n```go\nfunc NewItemFastSlowRateLimiter(fastDelay, slowDelay time.Duration, maxFastAttempts int) RateLimiter\n```\n\n```go\nfunc NewMaxOfRateLimiter(limiters ...RateLimiter) RateLimiter\n```\n\n```go\ntype RateLimitingInterface interface {\n\tDelayingInterface\n\n\t// AddRateLimited adds an item to the workqueue after the rate limiter says it's ok\n\tAddRateLimited(item interface{})\n\n\t// Forget indicates that an item is finished being retried.  Doesn't matter whether it's for perm failing\n\t// or for success, we'll stop the rate limiter from tracking it.  This only clears the `rateLimiter`, you\n\t// still have to call `Done` on the queue.\n\tForget(item interface{})\n\n\t// NumRequeues returns back how many times the item was requeued\n\tNumRequeues(item interface{}) int\n}\n```\nRateLimitingInterface is an interface that rate limits items being added to the queue.\n\n```go\nfunc NewNamedRateLimitingQueue(rateLimiter RateLimiter, name string) RateLimitingInterface\n```\n\n```go\nfunc NewRateLimitingQueue(rateLimiter RateLimiter) RateLimitingInterface\n```\nNewRateLimitingQueue constructs a new workqueue with rateLimited queuing ability Remember to call Forget!  If you don't, you may end up tracking failures forever.\n\n```go\ntype SettableGaugeMetric interface {\n\tSet(float64)\n}\n```\nSettableGaugeMetric represents a single numerical value that can arbitrarily go up and down. (Separate from GaugeMetric to preserve backwards compatibility.)\n\n```go\ntype SummaryMetric interface {\n\tObserve(float64)\n}\n```\nSummaryMetric captures individual observations.\n\n```go\ntype Type struct {\n\t// contains filtered or unexported fields\n}\n```\nType is a work queue (see the package comment).\n\n```go\nfunc New() *Type\n```\nNew constructs a new work queue (see the package comment).\n\n```go\nfunc NewNamed(name string) *Type\n```\n\n```go\nfunc (q *Type) Add(item interface{})\n```\nAdd marks item as needing processing.\n\n```go\nfunc (q *Type) Done(item interface{})\n```\nDone 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.\n\n```go\nfunc (q *Type) Get() (item interface{}, shutdown bool)\n```\nGet 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.\n\n```go\nfunc (q *Type) Len() int\n```\nLen 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.\n\n```go\nfunc (q *Type) ShutDown()\n```\nShutDown 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.\n\n```go\nfunc (q *Type) ShuttingDown() bool\n```\n\n","path":"github.com/unitytech/client-go/util/workqueue","name":"workqueue","synopsis":"Package workqueue provides a simple queue that supports the following features: * Fair: items processed in the order in which they are added.","isRedistributable":true}
