func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
	defer runtime.HandleCrash()
	defer c.workqueue.ShutDown()

	// Start the informer factories to begin populating the informer caches
	//glog.Info("Starting Foo controller")
	c.logger.Info("Starting controller")

	defer c.logger.Info("Exiting controller")

	// Wait for the caches to be synced before starting workers
	glog.Info("Waiting for informer caches to sync")
	if !cache.WaitForCacheSync(stopCh, c.cacheSyncs...) {
		c.logger.Fatal("Timeout waiting for cache to sync")
	}
	c.logger.Info("Sync completed")

	glog.Info("Starting workers")
	// Launch two workers to process Foo resources
	for i := 0; i < threadiness; i++ {
		go wait.Until(c.runWorker, time.Second, stopCh)
	}

	glog.Info("Started workers")
	<-stopCh
	glog.Info("Shutting down workers")

	return nil
}
// Run will set up the event handlers for types we are interested in, as well
// as syncing informer caches and starting workers. It will block until stopCh
// is closed, at which point it will shutdown the workqueue and wait for
// workers to finish processing their current work items.
Run will set up the event handlers for types we are interested in, as well
as syncing informer caches and starting workers. It will block until stopCh
is closed, at which point it will shutdown the workqueue and wait for
workers to finish processing their current work items.
// Run will set up the event handlers for types we are interested in as well // as syncing informer caches and starting workers . It will block until stopCh // is closed at which point it will shutdown the workqueue and wait for // workers to finish processing their current work items .
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
	defer runtime.HandleCrash()
	defer c.workqueue.ShutDown()
	c.logger.Info("Starting controller")
	defer c.logger.Info("Exiting controller")
	glog.Info("Waiting for informer caches to sync")
	if !cache.WaitForCacheSync(stopCh, c.cacheSyncs...) {
		c.logger.Fatal("Timeout waiting for cache to sync")
	}
	c.logger.Info("Sync completed")
	glog.Info("Starting workers")
	for i := 0; i < threadiness; i++ {
		go wait.Until(c.runWorker, time.Second, stopCh)
	}
	glog.Info("Started workers")
	<-stopCh
	glog.Info("Shutting down workers")
	return nil
}
func ( c * Controller ) Run ( threadiness int , stopCh <- chan struct { } ) error { defer runtime . HandleCrash ( ) defer c . workqueue . ShutDown ( ) c . logger . Info ( " " ) defer c . logger . Info ( " " ) glog . Info ( " " ) if ! cache . WaitForCacheSync ( stopCh , c . cacheSyncs ... ) { c . logger . Fatal ( " " ) } c . logger . Info ( " " ) glog . Info ( " " ) for i := 0 ; i < threadiness ; i ++ { go wait . Until ( c . runWorker , time . Second , stopCh ) } glog . Info ( " " ) <- stopCh glog . Info ( " " ) return nil }
Run will set up the event handlers for types we are interested in, as well
as syncing informer caches and starting workers.
Run will set up the event handlers for types we are interested in as well as syncing informer caches and starting workers .
// Start the informer factories to begin populating the informer caches //glog.Info("Starting Foo controller") // Wait for the caches to be synced before starting workers // Launch two workers to process Foo resources