When playground is created or modified it emits an event. (#225)

The scheduler listens to playground events and updates it's
configuration immediately.
This commit is contained in:
Jonathan Leibiusky
2017-11-23 13:40:06 -03:00
committed by Marcos Nils
parent 65b8364ef2
commit d758c1a303
4 changed files with 24 additions and 3 deletions

View File

@@ -308,6 +308,15 @@ func (s *scheduler) Start() error {
instance := &types.Instance{Name: instanceName}
s.unscheduleInstance(instance)
})
s.event.On(event.PLAYGROUND_NEW, func(playgroundId string, args ...interface{}) {
s.mx.Lock()
defer s.mx.Unlock()
log.Printf("EVENT: Playground New %s\n", playgroundId)
// We just update all playgrounds we manage to be safe. This is pretty fast anyway and this event should be fairly rare
s.updatePlaygrounds()
})
s.started = true
return nil