controller

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2015 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package controller provides reusable support for controller implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue added in v0.3.3

type Queue interface {
	Pop() interface{}
}

Queue is a narrow abstraction of a cache.FIFO.

type QueueRetryManager added in v0.3.3

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

QueueRetryManager retries a resource by re-queueing it into a ReQueue as long as retryFunc returns true.

func NewQueueRetryManager added in v0.3.3

func NewQueueRetryManager(queue ReQueue, keyFn kcache.KeyFunc, retryFn RetryFunc, limiter kutil.RateLimiter) *QueueRetryManager

NewQueueRetryManager safely creates a new QueueRetryManager.

func (*QueueRetryManager) Forget added in v0.3.3

func (r *QueueRetryManager) Forget(resource interface{})

Forget resets the retry count for resource.

func (*QueueRetryManager) Retry added in v0.3.3

func (r *QueueRetryManager) Retry(resource interface{}, err error)

Retry will enqueue resource until retryFunc returns false for that resource has been exceeded, at which point resource will be forgotten and no longer retried. The current retry count will be passed to each invocation of retryFunc.

type ReQueue added in v0.4.2

type ReQueue interface {
	Queue
	AddIfNotPresent(interface{}) error
}

ReQueue is a queue that allows an object to be requeued

type RetryController added in v0.3.3

type RetryController struct {
	// Queue is where work is retrieved for Handle.
	Queue

	// Handle is expected to process the next resource from the queue.
	Handle func(interface{}) error

	// RetryManager is fed the handled resource if Handle returns a Retryable
	// error. If Handle returns no error, the RetryManager is asked to forget
	// the resource.
	RetryManager
}

RetryController is a RunnableController which delegates resource handling to a function and knows how to safely manage retries of a resource which failed to be successfully handled.

func (*RetryController) Run added in v0.3.3

func (c *RetryController) Run()

Run begins processing resources from Queue asynchronously.

func (*RetryController) RunUntil added in v0.4.2

func (c *RetryController) RunUntil(stopCh <-chan struct{})

RunUntil begins processing resources from Queue asynchronously until stopCh is closed.

type RetryFunc added in v0.4.2

type RetryFunc func(obj interface{}, err error, retries int) bool

RetryFunc should return true if the given object and error should be retried after the provided number of times.

type RetryManager added in v0.3.3

type RetryManager interface {
	// Retry will cause resource processing to be retried (for example, by
	// requeueing resource)
	Retry(resource interface{}, err error)

	// Forget will cause the manager to erase all prior knowledge of resource
	// and reclaim internal resources associated with state tracking of
	// resource.
	Forget(resource interface{})
}

RetryManager knows how to retry processing of a resource, and how to forget a resource it may be tracking the state of.

type RunnableController added in v0.3.3

type RunnableController interface {
	// Run starts the asynchronous controller loop.
	Run()
}

RunnableController is a controller which implements a Run loop.

Jump to

Keyboard shortcuts

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