Documentation ¶
Index ¶
- Constants
- func DefaultRetryFunc(_ context.Context, _ string, timesTried int, _ time.Time, err error) (*time.Duration, error)
- type ItemHandler
- type Queue
- func (q *Queue) Empty() bool
- func (q *Queue) Enqueue(ctx context.Context, key string)
- func (q *Queue) EnqueueWithoutRateLimit(ctx context.Context, key string)
- func (q *Queue) EnqueueWithoutRateLimitWithDelay(ctx context.Context, key string, after time.Duration)
- func (q *Queue) Forget(ctx context.Context, key string)
- func (q *Queue) ItemsBeingProcessedLen() int
- func (q *Queue) Len() int
- func (q *Queue) Run(ctx context.Context, workers int)
- func (q *Queue) String() string
- func (q *Queue) UnprocessedLen() int
- type ShouldRetryFunc
Constants ¶
const (
// MaxRetries is the number of times we try to process a given key before permanently forgetting it.
MaxRetries = 20
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ItemHandler ¶
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 ¶
Empty returns if the queue has no items in it
It should only be used for debugging.
func (*Queue) EnqueueWithoutRateLimit ¶
EnqueueWithoutRateLimit enqueues the key without a rate limit
func (*Queue) EnqueueWithoutRateLimitWithDelay ¶
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) ItemsBeingProcessedLen ¶
ProcessedLen returns the count items that are being processed
func (*Queue) Run ¶
Run starts the workers
It blocks until context is cancelled, and all of the workers exit.
func (*Queue) UnprocessedLen ¶
UnprocessedLen returns the count of items yet to be processed in the queue