INNER CODE UNIT · Go
func
gravitational/workshop · crd/controller/controller.go:90
func (c *nginxController) Run(stopCh <-chan struct{}) error {
// Make sure to clean up the queue when done.
defer c.queue.ShutDown()
logrus.Info("Controller starting.")
// Launch the Nginx informer. It will watch for Nginx resources and
// call respective handlers registered above.
go c.nginxInformer.Informer().Run(stopCh)
// Before launching the worker, wait for informer's caches to sync.
if !cache.WaitForCacheSync(stopCh, c.nginxInformer.Informer().HasSynced) {
return trace.BadParameter("failed to sync informer cache")
}
// Launch the worker to process Nginx resources.
wait.Until(c.runWorker, time.Second, stopCh)
return nil
}
// runWorker iterates over the work queue and processes its items.
func (c *nginxController) runWorker() {