Version: v1.7.0 Latest Latest

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 12 Imported by: 0




View Source
const (
	// MaxRetries is the number of times we try to process a given key before permanently forgetting it.
	MaxRetries = 20


This section is empty.


func DefaultRetryFunc added in v1.6.0

func DefaultRetryFunc(ctx context.Context, key string, timesTried int, originallyAdded time.Time, err error) (*time.Duration, error)

DefaultRetryFunc is the default function used for retries by the queue subsystem.


type ItemHandler

type ItemHandler func(ctx context.Context, key string) error

ItemHandler is a callback that handles a single key on the Queue

type Queue

type Queue struct {
	// contains filtered or unexported fields

Queue implements a wrapper around workqueue with native VK instrumentation

func New

func New(ratelimiter workqueue.RateLimiter, name string, handler ItemHandler, retryFunc ShouldRetryFunc) *Queue

New creates a queue

It expects to get a item rate limiter, and a friendly name which is used in logs, and in the internal kubernetes metrics. If retryFunc is nil, the default retry function.

func (*Queue) Empty

func (q *Queue) Empty() bool

Empty returns if the queue has no items in it

It should only be used for debugging.

func (*Queue) Enqueue

func (q *Queue) Enqueue(ctx context.Context, key string)

Enqueue enqueues the key in a rate limited fashion

func (*Queue) EnqueueWithoutRateLimit

func (q *Queue) EnqueueWithoutRateLimit(ctx context.Context, key string)

EnqueueWithoutRateLimit enqueues the key without a rate limit

func (*Queue) EnqueueWithoutRateLimitWithDelay added in v1.5.0

func (q *Queue) EnqueueWithoutRateLimitWithDelay(ctx context.Context, key string, after time.Duration)

EnqueueWithoutRateLimitWithDelay enqueues without rate limiting, but work will not start for this given delay period

func (*Queue) Forget

func (q *Queue) Forget(ctx context.Context, key string)

Forget forgets the key

func (*Queue) Len added in v1.5.0

func (q *Queue) Len() int

Len includes items that are in the queue, and are being processed

func (*Queue) Run

func (q *Queue) Run(ctx context.Context, workers int)

Run starts the workers

It blocks until context is cancelled, and all of the workers exit.

func (*Queue) String added in v1.5.0

func (q *Queue) String() string

type ShouldRetryFunc added in v1.6.0

type ShouldRetryFunc func(ctx context.Context, key string, timesTried int, originallyAdded time.Time, err error) (*time.Duration, error)

ShouldRetryFunc is a mechanism to have a custom retry policy

Source Files

Jump to

Keyboard shortcuts

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