diff --git a/pkg/source/source.go b/pkg/source/source.go index 866ac5236e..be5143f58b 100644 --- a/pkg/source/source.go +++ b/pkg/source/source.go @@ -229,30 +229,6 @@ func (cs *Channel) Stop() error { return cs.group.Wait() } -var _ Source = Func(nil) - -// Func is a function that implements Source. -// Deprecated: use manually implemented Source instead. -type Func func(context.Context, handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error - -// Start is internal and should be called only by the Controller to register an EventHandler with the Informer -// to enqueue reconcile.Requests. -func (f Func) Start(ctx context.Context, evt handler.EventHandler, queue workqueue.RateLimitingInterface, - pr ...predicate.Predicate) error { - return f(ctx, evt, queue, pr...) -} - -// Stop is internal and should be called only by the Controller to stop the Source. It should block until the -// Source has stopped. -// WARNING: will always return an error. -func (f Func) Stop() error { - return fmt.Errorf("Func source is not stoppable") -} - -func (f Func) String() string { - return fmt.Sprintf("func source: %p", f) -} - // Informer is used to provide a source of events originating inside the cluster from Watches (e.g. Pod Create). type Informer struct { // Informer is the controller-runtime Informer @@ -323,3 +299,27 @@ func (is *Informer) Stop() error { func (is *Informer) String() string { return fmt.Sprintf("informer source: %p", is.Informer) } + +var _ Source = Func(nil) + +// Func is a function that implements Source. +// Deprecated: use manually implemented Source instead. +type Func func(context.Context, handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error + +// Start is internal and should be called only by the Controller to register an EventHandler with the Informer +// to enqueue reconcile.Requests. +func (f Func) Start(ctx context.Context, evt handler.EventHandler, queue workqueue.RateLimitingInterface, + pr ...predicate.Predicate) error { + return f(ctx, evt, queue, pr...) +} + +// Stop is internal and should be called only by the Controller to stop the Source. It should block until the +// Source has stopped. +// WARNING: will always return an error. +func (f Func) Stop() error { + return fmt.Errorf("Func source is not stoppable") +} + +func (f Func) String() string { + return fmt.Sprintf("func source: %p", f) +}