{"modulePath":"github.com/stackpointcloud/kubernetes","version":"v1.3.2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package framework\n\nPackage framework implements all the grunt work involved in running a simple controller.\n\n## Functions\n\n```go\nfunc DeletionHandlingMetaNamespaceKeyFunc(obj interface{}) (string, error)\n```\nDeletionHandlingMetaNamespaceKeyFunc checks for cache.DeletedFinalStateUnknown objects before calling cache.MetaNamespaceKeyFunc.\n\n## Types\n\n```go\ntype Config struct {\n\t// The queue for your objects; either a cache.FIFO or\n\t// a cache.DeltaFIFO. Your Process() function should accept\n\t// the output of this Oueue's Pop() method.\n\tcache.Queue\n\n\t// Something that can list and watch your objects.\n\tcache.ListerWatcher\n\n\t// Something that can process your objects.\n\tProcess ProcessFunc\n\n\t// The type of your objects.\n\tObjectType runtime.Object\n\n\t// Reprocess everything at least this often.\n\t// Note that if it takes longer for you to clear the queue than this\n\t// period, you will end up processing items in the order determined\n\t// by cache.FIFO.Replace(). Currently, this is random. If this is a\n\t// problem, we can change that replacement policy to append new\n\t// things to the end of the queue instead of replacing the entire\n\t// queue.\n\tFullResyncPeriod time.Duration\n\n\t// If true, when Process() returns an error, re-enqueue the object.\n\t// TODO: add interface to let you inject a delay/backoff or drop\n\t//       the object completely if desired. Pass the object in\n\t//       question to this interface as a parameter.\n\tRetryOnError bool\n}\n```\nConfig contains all the settings for a Controller.\n\n```go\ntype Controller struct {\n\t// contains filtered or unexported fields\n}\n```\nController is a generic controller framework.\n\n```go\nfunc New(c *Config) *Controller\n```\nNew makes a new Controller from the given Config.\n\n```go\nfunc NewIndexerInformer(\n\tlw cache.ListerWatcher,\n\tobjType runtime.Object,\n\tresyncPeriod time.Duration,\n\th ResourceEventHandler,\n\tindexers cache.Indexers,\n) (cache.Indexer, *Controller)\n```\nNewIndexerInformer returns a cache.Indexer and a controller for populating the index while also providing event notifications. You should only used the returned cache.Index for Get/List operations; Add/Modify/Deletes will cause the event notifications to be faulty.\n\nParameters:\n\n  - lw is list and watch functions for the source of the resource you want to be informed of.\n  - objType is an object of the type that you expect to receive.\n  - resyncPeriod: if non-zero, will re-list this often (you will get OnUpdate calls, even if nothing changed). Otherwise, re-list will be delayed as long as possible (until the upstream source closes the watch or times out, or you stop the controller).\n  - h is the object you want notifications sent to.\n\n```go\nfunc NewInformer(\n\tlw cache.ListerWatcher,\n\tobjType runtime.Object,\n\tresyncPeriod time.Duration,\n\th ResourceEventHandler,\n) (cache.Store, *Controller)\n```\nNewInformer returns a cache.Store and a controller for populating the store while also providing event notifications. You should only used the returned cache.Store for Get/List operations; Add/Modify/Deletes will cause the event notifications to be faulty.\n\nParameters:\n\n  - lw is list and watch functions for the source of the resource you want to be informed of.\n  - objType is an object of the type that you expect to receive.\n  - resyncPeriod: if non-zero, will re-list this often (you will get OnUpdate calls, even if nothing changed). Otherwise, re-list will be delayed as long as possible (until the upstream source closes the watch or times out, or you stop the controller).\n  - h is the object you want notifications sent to.\n\n```go\nfunc (c *Controller) HasSynced() bool\n```\nReturns true once this controller has completed an initial resource listing\n\n```go\nfunc (c *Controller) Requeue(obj interface{}) error\n```\nRequeue adds the provided object back into the queue if it does not already exist.\n\n```go\nfunc (c *Controller) Run(stopCh \u003c-chan struct{})\n```\nRun begins processing items, and will continue until a value is sent down stopCh. It's an error to call Run more than once. Run blocks; call via go.\n\n```go\ntype ControllerInterface interface {\n\tRun(stopCh \u003c-chan struct{})\n\tHasSynced() bool\n}\n```\nTODO make the \"Controller\" private, and convert all references to use ControllerInterface instead\n\n```go\ntype FakeControllerSource struct {\n\tItems map[nnu]runtime.Object\n\n\tBroadcaster *watch.Broadcaster\n\t// contains filtered or unexported fields\n}\n```\nFakeControllerSource implements listing/watching for testing.\n\n```go\nfunc NewFakeControllerSource() *FakeControllerSource\n```\n\n```go\nfunc (f *FakeControllerSource) Add(obj runtime.Object)\n```\nAdd adds an object to the set and sends an add event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) AddDropWatch(obj runtime.Object)\n```\nAddDropWatch adds an object to the set but forgets to send an add event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) Change(e watch.Event, watchProbability float64)\n```\nChange records the given event (setting the object's resource version) and sends a watch event with the specified probability.\n\n```go\nfunc (f *FakeControllerSource) Delete(lastValue runtime.Object)\n```\nDelete deletes an object from the set and sends a delete event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) DeleteDropWatch(lastValue runtime.Object)\n```\nDeleteDropWatch deletes an object from the set but forgets to send a delete event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error)\n```\nList returns a list object, with its resource version set.\n\n```go\nfunc (f *FakeControllerSource) Modify(obj runtime.Object)\n```\nModify updates an object in the set and sends a modified event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) ModifyDropWatch(obj runtime.Object)\n```\nModifyDropWatch updates an object in the set but forgets to send a modify event to watchers. obj's ResourceVersion is set.\n\n```go\nfunc (f *FakeControllerSource) Shutdown()\n```\nShutdown closes the underlying broadcaster, waiting for events to be delivered. It's an error to call any method after calling shutdown. This is enforced by Shutdown() leaving f locked.\n\n```go\nfunc (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error)\n```\nWatch returns a watch, which will be pre-populated with all changes after resourceVersion.\n\n```go\ntype FakePVCControllerSource struct {\n\tFakeControllerSource\n}\n```\n\n```go\nfunc NewFakePVCControllerSource() *FakePVCControllerSource\n```\n\n```go\nfunc (f *FakePVCControllerSource) List(options api.ListOptions) (runtime.Object, error)\n```\nList returns a list object, with its resource version set.\n\n```go\ntype FakePVControllerSource struct {\n\tFakeControllerSource\n}\n```\n\n```go\nfunc NewFakePVControllerSource() *FakePVControllerSource\n```\n\n```go\nfunc (f *FakePVControllerSource) List(options api.ListOptions) (runtime.Object, error)\n```\nList returns a list object, with its resource version set.\n\n```go\ntype ProcessFunc func(obj interface{}) error\n```\nProcessFunc processes a single object.\n\n```go\ntype ResourceEventHandler interface {\n\tOnAdd(obj interface{})\n\tOnUpdate(oldObj, newObj interface{})\n\tOnDelete(obj interface{})\n}\n```\nResourceEventHandler can handle notifications for events that happen to a resource.  The events are informational only, so you can't return an error.\n\n  - OnAdd is called when an object is added.\n  - OnUpdate is called when an object is modified. Note that oldObj is the last known state of the object-- it is possible that several changes were combined together, so you can't use this to see every single change. OnUpdate is also called when a re-list happens, and it will get called even if nothing changed. This is useful for periodically evaluating or syncing something.\n  - OnDelete will get the final state of the item if it is known, otherwise it will get an object of type cache.DeletedFinalStateUnknown. This can happen if the watch is closed and misses the delete event and we don't notice the deletion until the subsequent re-list.\n\n```go\ntype ResourceEventHandlerFuncs struct {\n\tAddFunc    func(obj interface{})\n\tUpdateFunc func(oldObj, newObj interface{})\n\tDeleteFunc func(obj interface{})\n}\n```\nResourceEventHandlerFuncs is an adaptor to let you easily specify as many or as few of the notification functions as you want while still implementing ResourceEventHandler.\n\n```go\nfunc (r ResourceEventHandlerFuncs) OnAdd(obj interface{})\n```\nOnAdd calls AddFunc if it's not nil.\n\n```go\nfunc (r ResourceEventHandlerFuncs) OnDelete(obj interface{})\n```\nOnDelete calls DeleteFunc if it's not nil.\n\n```go\nfunc (r ResourceEventHandlerFuncs) OnUpdate(oldObj, newObj interface{})\n```\nOnUpdate calls UpdateFunc if it's not nil.\n\n```go\ntype SharedIndexInformer interface {\n\tSharedInformer\n\t// AddIndexers add indexers to the informer before it starts.\n\tAddIndexers(indexers cache.Indexers) error\n\tGetIndexer() cache.Indexer\n}\n```\n\n```go\nfunc NewSharedIndexInformer(lw cache.ListerWatcher, objType runtime.Object, resyncPeriod time.Duration, indexers cache.Indexers) SharedIndexInformer\n```\nNewSharedIndexInformer creates a new instance for the listwatcher. TODO: create a cache/factory of these at a higher level for the list all, watch all of a given resource that can be shared amongst all consumers.\n\n```go\ntype SharedInformer interface {\n\t// events to a single handler are delivered sequentially, but there is no coordination between different handlers\n\t// You may NOT add a handler *after* the SharedInformer is running.  That will result in an error being returned.\n\t// TODO we should try to remove this restriction eventually.\n\tAddEventHandler(handler ResourceEventHandler) error\n\tGetStore() cache.Store\n\t// GetController gives back a synthetic interface that \"votes\" to start the informer\n\tGetController() ControllerInterface\n\tRun(stopCh \u003c-chan struct{})\n\tHasSynced() bool\n}\n```\nif you use this, there is one behavior change compared to a standard Informer. When you receive a notification, the cache will be AT LEAST as fresh as the notification, but it MAY be more fresh.  You should NOT depend on the contents of the cache exactly matching the notification you've received in handler functions.  If there was a create, followed by a delete, the cache may NOT have your item.  This has advantages over the broadcaster since it allows us to share a common cache across many controllers. Extending the broadcaster would have required us keep duplicate caches for each watch.\n\n```go\nfunc NewSharedInformer(lw cache.ListerWatcher, objType runtime.Object, resyncPeriod time.Duration) SharedInformer\n```\nNewSharedInformer creates a new instance for the listwatcher. TODO: create a cache/factory of these at a higher level for the list all, watch all of a given resource that can be shared amongst all consumers.\n\n","path":"github.com/stackpointcloud/kubernetes/pkg/controller/framework","name":"framework","synopsis":"Package framework implements all the grunt work involved in running a simple controller.","isRedistributable":true}
