From 61c7beb51f32b30e0dbda54bc30d5c474f4909d4 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Thu, 4 Jun 2015 15:55:15 -0400 Subject: [PATCH] Add an Enqueue method to framework.Controller Allows clients to requeue delta events in the event they need to delay processing. --- pkg/controller/framework/controller.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/controller/framework/controller.go b/pkg/controller/framework/controller.go index bb839b3cd98..ca182343aa4 100644 --- a/pkg/controller/framework/controller.go +++ b/pkg/controller/framework/controller.go @@ -106,6 +106,16 @@ func (c *Controller) HasSynced() bool { return c.reflector.LastSyncResourceVersion() != "" } +// Requeue adds the provided object back into the queue if it does not already exist. +func (c *Controller) Requeue(obj interface{}) error { + return c.config.Queue.AddIfNotPresent(cache.Deltas{ + cache.Delta{ + Type: cache.Sync, + Object: obj, + }, + }) +} + // processLoop drains the work queue. // TODO: Consider doing the processing in parallel. This will require a little thought // to make sure that we don't end up processing the same object multiple times