func (c *Controller) processNextQueueItem() bool {
	c.logger.Debug("Controller.processNextQueueItem: start")
	item, quit := c.queue.Get()
	c.logger.Debug("Controller.processNextQueueItem: item fetched")
	if quit {
		return false
	}
	defer c.queue.Done(item)
	indexKey, err := cache.MetaNamespaceKeyFunc(item)
	if err != nil {
		c.queue.Forget(item)
		utilruntime.HandleError(err)
		return true
	}
	_, exists, err := c.informer.GetIndexer().GetByKey(indexKey)
	if err != nil {
		if c.queue.NumRequeues(item) < 5 {
			c.logger.Errorf("Controller.processNextQueueItem: Failed processing item with item %s with error %v, retrying", item, err)
			c.queue.AddRateLimited(item)
		} else {
			c.logger.Errorf("Controller.processNextQueueItem: Failed processing item with item %s with error %v, no more retries", item, err)
			c.queue.Forget(item)
			utilruntime.HandleError(err)
		}
	}
	if !exists {
		c.logger.Debugf("Controller.processNextQueueItem: object deleted detected: %s", indexKey)
		c.handler.ObjectDeleted(c.clientset, item)
		c.queue.Forget(item)
	} else {
		c.logger.Debugf("Controller.processNextQueueItem: object created detected: %s", indexKey)
		c.handler.ObjectCreated(c.clientset, item)
		c.queue.Forget(item)
	}
	return true
}
processNextQueueItem retrieves each queued item and takes the
necessary handler action based off of if the item was
created or deleted
package main
import (
	"fmt"
	"time"
	log "github.com/Sirupsen/logrus"
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/apimachinery/pkg/util/wait"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/cache"
	"k8s.io/client-go/util/workqueue"
)
type Controller struct {
	logger    *log.Entry
	clientset kubernetes.Interface
	queue     workqueue.RateLimitingInterface
	informer  cache.SharedIndexInformer
	handler   Handler
}
func (c *Controller) Run(stopCh <-chan struct{}) {
	defer utilruntime.HandleCrash()
	defer c.queue.ShutDown()
	c.logger.Debug("Controller.Run: initiating")
	go c.informer.Run(stopCh)
	if !cache.WaitForCacheSync(stopCh, c.informer.HasSynced) {
		utilruntime.HandleError(fmt.Errorf("Error syncing cache"))
		return
	}
	c.logger.Debug("Controller.Run: cache sync complete")
	wait.Until(c.runWorker, time.Second, stopCh)
}
func (c *Controller) runWorker() {
	c.logger.Debug("Controller.runWorker: starting")
	for c.processNextQueueItem() {
		c.logger.Debug("Controller.runWorker: processing next item")
	}
	c.logger.Debug("Controller.runWorker: completed")
}