{"modulePath":"github.com/mtrmac/origin","version":"v1.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controller\n\nPackage controller provides reusable support for controller implementations.\n\n## Functions\n\n```go\nfunc RetryAlways(obj interface{}, err error, retries Retry) bool\n```\nRetryNever is a RetryFunc implementation that will always retry\n\n```go\nfunc RetryNever(obj interface{}, err error, retries Retry) bool\n```\nRetryNever is a RetryFunc implementation that will never retry\n\n## Types\n\n```go\ntype Queue interface {\n\tPop(kcache.PopProcessFunc) (interface{}, error)\n}\n```\nQueue is a narrow abstraction of a cache.FIFO.\n\n```go\ntype QueueRetryManager struct {\n\t// contains filtered or unexported fields\n}\n```\nQueueRetryManager retries a resource by re-queueing it into a ReQueue as long as retryFunc returns true.\n\n```go\nfunc NewQueueRetryManager(queue ReQueue, keyFn kcache.KeyFunc, retryFn RetryFunc, limiter flowcontrol.RateLimiter) *QueueRetryManager\n```\nNewQueueRetryManager safely creates a new QueueRetryManager.\n\n```go\nfunc (r *QueueRetryManager) Forget(resource interface{})\n```\nForget resets the retry count for resource.\n\n```go\nfunc (r *QueueRetryManager) Retry(resource interface{}, err error)\n```\nRetry 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.\n\n```go\ntype ReQueue interface {\n\tQueue\n\tAddIfNotPresent(interface{}) error\n}\n```\nReQueue is a queue that allows an object to be requeued\n\n```go\ntype Retry struct {\n\t// Count is the number of retries\n\tCount int\n\n\t// StartTimestamp is retry start timestamp\n\tStartTimestamp unversioned.Time\n}\n```\nRetry describes provides additional information regarding retries.\n\n```go\ntype RetryController struct {\n\t// Queue is where work is retrieved for Handle.\n\tQueue\n\n\t// Handle is expected to process the next resource from the queue.\n\tHandle func(interface{}) error\n\n\t// RetryManager is fed the handled resource if Handle returns a Retryable\n\t// error. If Handle returns no error, the RetryManager is asked to forget\n\t// the resource.\n\tRetryManager\n}\n```\nRetryController 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.\n\n```go\nfunc (c *RetryController) Run()\n```\nRun begins processing resources from Queue asynchronously.\n\n```go\nfunc (c *RetryController) RunUntil(stopCh \u003c-chan struct{})\n```\nRunUntil begins processing resources from Queue asynchronously until stopCh is closed.\n\n```go\ntype RetryFunc func(obj interface{}, err error, retries Retry) bool\n```\nRetryFunc should return true if the given object and error should be retried after the provided number of times.\n\n```go\ntype RetryManager interface {\n\t// Retry will cause resource processing to be retried (for example, by\n\t// requeueing resource)\n\tRetry(resource interface{}, err error)\n\n\t// Forget will cause the manager to erase all prior knowledge of resource\n\t// and reclaim internal resources associated with state tracking of\n\t// resource.\n\tForget(resource interface{})\n}\n```\nRetryManager knows how to retry processing of a resource, and how to forget a resource it may be tracking the state of.\n\n```go\ntype RunnableController interface {\n\t// Run starts the asynchronous controller loop.\n\tRun()\n}\n```\nRunnableController is a controller which implements a Run loop.\n\n```go\ntype Scheduler struct {\n\t// contains filtered or unexported fields\n}\n```\nScheduler is a self-balancing, rate-limited, bucketed queue that can periodically invoke an action on all items in a bucket before moving to the next bucket. A ratelimiter sets an upper bound on the number of buckets processed per unit time. The queue has a key and a value, so both uniqueness and equality can be tested (key must be unique, value can carry info for the next processing). Items remain in the queue until removed by a call to Remove().\n\n```go\nfunc NewScheduler(bucketCount int, bucketLimiter flowcontrol.RateLimiter, fn func(key, value interface{})) *Scheduler\n```\nNewScheduler creates a scheduler with bucketCount buckets, a rate limiter for restricting the rate at which buckets are processed, and a function to invoke when items are scanned in a bucket. TODO: remove DEBUG statements from this file once this logic has been adequately validated.\n\n```go\nfunc (s *Scheduler) Add(key, value interface{})\n```\nAdd places the key in the bucket with the least entries (except the current bucket). The key is used to determine uniqueness, while value can be used to associate additional data for later retrieval. An Add removes the previous key and value and will place the item in a new bucket. This allows callers to ensure that Add'ing a new item to the queue purges old versions of the item, while Remove can be conditional on removing only the known old version.\n\n```go\nfunc (s *Scheduler) Delay(key interface{})\n```\nDelay moves the key to the end of the chain if it exists.\n\n```go\nfunc (s *Scheduler) Len() int\n```\nLen returns the number of scheduled items.\n\n```go\nfunc (s *Scheduler) Map() map[interface{}]interface{}\n```\nMap returns a copy of the scheduler contents, but does not copy the keys or values themselves. If values and keys are not immutable, changing the value will affect the value in the queue.\n\n```go\nfunc (s *Scheduler) Remove(key, value interface{}) bool\n```\nRemove takes the key out of all buckets. If value is non-nil, the key will only be removed if it has the same value. Returns true if the key was removed.\n\n```go\nfunc (s *Scheduler) RunOnce()\n```\nRunOnce takes a single item out of the current bucket and processes it. If the bucket is empty, we wait for the rate limiter before returning.\n\n```go\nfunc (s *Scheduler) RunUntil(ch \u003c-chan struct{})\n```\nRunUntil launches the scheduler until ch is closed.\n\n```go\ntype StoppableController interface {\n\t// RunUntil starts the asynchronous controller loop, which runs until\n\t// ch is closed.\n\tRunUntil(ch \u003c-chan struct{})\n}\n```\nStoppableController is a controller which implements a Run loop.\n\n","path":"github.com/mtrmac/origin/pkg/controller","name":"controller","synopsis":"Package controller provides reusable support for controller implementations.","isRedistributable":true}
