{"modulePath":"github.com/knative/pkg","version":"v0.0.0-20200513152158-87426b54db6f","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controller\n\n## Constants\n\n```go\nconst (\n\n\t// DefaultResyncPeriod is the default duration that is used when no\n\t// resync period is associated with a controllers initialization context.\n\tDefaultResyncPeriod = 10 * time.Hour\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// DefaultThreadsPerController is the number of threads to use\n\t// when processing the controller's workqueue.  Controller binaries\n\t// may adjust this process-wide default.  For finer control, invoke\n\t// Run on the controller directly.\n\tDefaultThreadsPerController = 2\n)\n```\n\n## Functions\n\n```go\nfunc Filter(gvk schema.GroupVersionKind) func(obj interface{}) bool\n```\nFilter makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on the schema.GroupVersionKind of the controlling resources.\n\nDeprecated: Use FilterGroupVersionKind or FilterGroupKind instead\n\n```go\nfunc FilterGroupKind(gk schema.GroupKind) func(obj interface{}) bool\n```\nFilterGroupKind makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on the schema.GroupKind of the controlling resources.\n\n```go\nfunc FilterGroupVersionKind(gvk schema.GroupVersionKind) func(obj interface{}) bool\n```\nFilterGroupVersionKind makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on the schema.GroupVersionKind of the controlling resources.\n\n```go\nfunc FilterWithName(name string) func(obj interface{}) bool\n```\nFilterWithName makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on a name.\n\n```go\nfunc FilterWithNameAndNamespace(namespace, name string) func(obj interface{}) bool\n```\nFilterWithNameAndNamespace makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on a namespace and a name.\n\n```go\nfunc GetEventRecorder(ctx context.Context) record.EventRecorder\n```\nGetEventRecorder attempts to look up the record.EventRecorder on a given context. It may return null if none is found.\n\n```go\nfunc GetResyncPeriod(ctx context.Context) time.Duration\n```\nGetResyncPeriod returns the resync period associated with the given context. When none is specified a default resync period is used.\n\n```go\nfunc GetTrackerLease(ctx context.Context) time.Duration\n```\nGetTrackerLease fetches the tracker lease from the controller context.\n\n```go\nfunc HandleAll(h func(interface{})) cache.ResourceEventHandler\n```\nHandleAll wraps the provided handler function into a cache.ResourceEventHandler that sends all events to the given handler.  For Updates, only the new object is forwarded.\n\n```go\nfunc IsPermanentError(err error) bool\n```\nIsPermanentError returns true if given error is permanentError\n\n```go\nfunc NewPermanentError(err error) error\n```\nNewPermanentError returns a new instance of permanentError. Users can wrap an error as permanentError with this in reconcile, when he does not expect the key to get re-queued.\n\n```go\nfunc PassNew(f func(interface{})) func(interface{}, interface{})\n```\nPassNew makes it simple to create an UpdateFunc for use with cache.ResourceEventHandlerFuncs that can delegate the same methods as AddFunc/DeleteFunc but passing through only the second argument (which is the \"new\" object).\n\n```go\nfunc RunInformers(stopCh \u003c-chan struct{}, informers ...Informer) (func(), error)\n```\nRunInformers kicks off all of the passed informers and then waits for all of them to synchronize. Returned function will wait for all informers to finish.\n\n```go\nfunc StartAll(stopCh \u003c-chan struct{}, controllers ...*Impl)\n```\nStartAll kicks off all of the passed controllers with DefaultThreadsPerController.\n\n```go\nfunc StartInformers(stopCh \u003c-chan struct{}, informers ...Informer) error\n```\nStartInformers kicks off all of the passed informers and then waits for all of them to synchronize.\n\n```go\nfunc WithEventRecorder(ctx context.Context, er record.EventRecorder) context.Context\n```\nWithEventRecorder attaches the given record.EventRecorder to the provided context in the returned context.\n\n```go\nfunc WithResyncPeriod(ctx context.Context, resync time.Duration) context.Context\n```\nWithResyncPeriod associates the given resync period with the given context in the context that is returned.\n\n## Types\n\n```go\ntype Callback func(interface{})\n```\n\n```go\nfunc EnsureTypeMeta(f Callback, gvk schema.GroupVersionKind) Callback\n```\n\n```go\ntype Impl struct {\n\t// Reconciler is the workhorse of this controller, it is fed the keys\n\t// from the workqueue to process.  Public for testing.\n\tReconciler Reconciler\n\n\t// WorkQueue is a rate limited work queue. This is used to queue work to be\n\t// processed instead of performing it as soon as a change happens. This\n\t// means we can ensure we only process a fixed amount of resources at a\n\t// time, and makes it easy to ensure we are never processing the same item\n\t// simultaneously in two different workers.\n\tWorkQueue workqueue.RateLimitingInterface\n\t// contains filtered or unexported fields\n}\n```\nImpl is our core controller implementation.  It handles queuing and feeding work from the queue to an implementation of Reconciler.\n\n```go\nfunc NewImpl(r Reconciler, logger *zap.SugaredLogger, workQueueName string) *Impl\n```\nNewImpl instantiates an instance of our controller that will feed work to the provided Reconciler as it is enqueued.\n\n```go\nfunc NewImplWithStats(r Reconciler, logger *zap.SugaredLogger, workQueueName string, reporter StatsReporter) *Impl\n```\n\n```go\nfunc (c *Impl) Enqueue(obj interface{})\n```\nEnqueue takes a resource, converts it into a namespace/name string, and passes it to EnqueueKey.\n\n```go\nfunc (c *Impl) EnqueueAfter(obj interface{}, after time.Duration)\n```\nEnqueueAfter takes a resource, converts it into a namespace/name string, and passes it to EnqueueKey.\n\n```go\nfunc (c *Impl) EnqueueControllerOf(obj interface{})\n```\nEnqueueControllerOf takes a resource, identifies its controller resource, converts it into a namespace/name string, and passes that to EnqueueKey.\n\n```go\nfunc (c *Impl) EnqueueKey(key types.NamespacedName)\n```\nEnqueueKey takes a namespace/name string and puts it onto the work queue.\n\n```go\nfunc (c *Impl) EnqueueKeyAfter(key types.NamespacedName, delay time.Duration)\n```\nEnqueueKeyAfter takes a namespace/name string and schedules its execution in the work queue after given delay.\n\n```go\nfunc (c *Impl) EnqueueLabelOfClusterScopedResource(nameLabel string) func(obj interface{})\n```\nEnqueueLabelOfClusterScopedResource returns with an Enqueue func that takes a resource, identifies its controller resource through given name label, and passes it to EnqueueKey. The controller resource must be of cluster-scoped.\n\n```go\nfunc (c *Impl) EnqueueLabelOfNamespaceScopedResource(namespaceLabel, nameLabel string) func(obj interface{})\n```\nEnqueueLabelOfNamespaceScopedResource returns with an Enqueue func that takes a resource, identifies its controller resource through given namespace and name labels, converts it into a namespace/name string, and passes that to EnqueueKey. The controller resource must be of namespace-scoped.\n\n```go\nfunc (c *Impl) EnqueueSentinel(k types.NamespacedName) func(interface{})\n```\nEnqueueSentinel returns a Enqueue method which will always enqueue a predefined key instead of the object key.\n\n```go\nfunc (c *Impl) FilteredGlobalResync(f func(interface{}) bool, si cache.SharedInformer)\n```\nFilteredGlobalResync enqueues (with a delay) all objects from the SharedInformer that pass the filter function\n\n```go\nfunc (c *Impl) GlobalResync(si cache.SharedInformer)\n```\nGlobalResync enqueues (with a delay) all objects from the passed SharedInformer\n\n```go\nfunc (c *Impl) Run(threadiness int, stopCh \u003c-chan struct{}) error\n```\nRun starts the controller's worker threads, the number of which is threadiness. It then blocks until stopCh is closed, at which point it shuts down its internal work queue and waits for workers to finish processing their current work items.\n\n```go\ntype Informer interface {\n\tRun(\u003c-chan struct{})\n\tHasSynced() bool\n}\n```\nInformer is the group of methods that a type must implement to be passed to StartInformers.\n\n```go\ntype Options struct {\n\t// ConfigStore is used to attach the frozen configuration to the context.\n\tConfigStore reconciler.ConfigStore\n}\n```\nOptions is additional resources a Controller might want to use depending on implementation.\n\n```go\ntype OptionsFn func(impl *Impl) Options\n```\nOptionsFn is a callback method signature that accepts an Impl and returns Options. Used for controllers that need access to the members of Options but to build Options, integrators need an Impl.\n\n```go\ntype Reconciler interface {\n\tReconcile(ctx context.Context, key string) error\n}\n```\nReconciler is the interface that controller implementations are expected to implement, so that the shared controller.Impl can drive work through it.\n\n```go\ntype StatsReporter interface {\n\t// ReportQueueDepth reports the queue depth metric\n\tReportQueueDepth(v int64) error\n\n\t// ReportReconcile reports the count and latency metrics for a reconcile operation\n\tReportReconcile(duration time.Duration, key, success string) error\n}\n```\nStatsReporter defines the interface for sending metrics\n\n```go\nfunc MustNewStatsReporter(reconciler string, logger *zap.SugaredLogger) StatsReporter\n```\nMustNewStatsReporter creates a new instance of StatsReporter. Logs fatally if creation fails.\n\n```go\nfunc NewStatsReporter(reconciler string) (StatsReporter, error)\n```\nNewStatsReporter creates a reporter that collects and reports metrics\n\n","path":"github.com/knative/pkg/controller","name":"controller","synopsis":"","isRedistributable":true}
