Skip to content

Commit

Permalink
switch to require 'go controller.Run()'
Browse files Browse the repository at this point in the history
  • Loading branch information
lavalamp committed Apr 9, 2015
1 parent 54be979 commit a44e81b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/controller/framework/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,17 @@ func New(c *Config) *Controller {

// Run begins processing items, and will continue until a value is sent down stopCh.
// It's an error to call Run more than once.
// Run does not block.
// Run blocks; call via go.
func (c *Controller) Run(stopCh <-chan struct{}) {
defer util.HandleCrash()
cache.NewReflector(
c.config.ListerWatcher,
c.config.ObjectType,
c.config.Queue,
c.config.FullResyncPeriod,
).RunUntil(stopCh)

go util.Until(c.processLoop, time.Second, stopCh)
util.Until(c.processLoop, time.Second, stopCh)
}

// processLoop drains the work queue.
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/framework/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func Example() {

// Create the controller and run it until we close stop.
stop := make(chan struct{})
framework.New(cfg).Run(stop)
go framework.New(cfg).Run(stop)

// Let's add a few objects to the source.
for _, name := range []string{"a-hello", "b-controller", "c-framework"} {
Expand Down Expand Up @@ -151,7 +151,7 @@ func ExampleInformer() {

// Run the controller and run it until we close stop.
stop := make(chan struct{})
controller.Run(stop)
go controller.Run(stop)

// Let's add a few objects to the source.
for _, name := range []string{"a-hello", "b-controller", "c-framework"} {
Expand Down
2 changes: 1 addition & 1 deletion plugin/pkg/scheduler/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys util.StringSe
cache.NewReflector(f.createUnassignedPodLW(), &api.Pod{}, f.PodQueue, 0).RunUntil(f.StopEverything)

// Begin populating scheduled pods.
f.scheduledPodPopulator.Run(f.StopEverything)
go f.scheduledPodPopulator.Run(f.StopEverything)

// Watch minions.
// Minions may be listed frequently, so provide a local up-to-date cache.
Expand Down

0 comments on commit a44e81b

Please sign in to comment.