Use queues for the pod events (#30)

This commit is contained in:
Murat Kabilov
2017-05-23 15:24:14 +02:00
committed by GitHub
parent 132c8425e6
commit 009db16c7c
6 changed files with 96 additions and 79 deletions
-17
View File
@@ -146,23 +146,6 @@ func (c *Cluster) recreatePod(pod v1.Pod) error {
return nil
}
func (c *Cluster) podEventsDispatcher(stopCh <-chan struct{}) {
c.logger.Infof("Watching '%s' cluster", c.ClusterName())
for {
select {
case event := <-c.podEvents:
c.podSubscribersMu.RLock()
subscriber, ok := c.podSubscribers[event.PodName]
c.podSubscribersMu.RUnlock()
if ok {
go func() { subscriber <- event }() //TODO: is it a right way to do nonblocking send to the channel?
}
case <-stopCh:
return
}
}
}
func (c *Cluster) recreatePods() error {
ls := c.labelsSet()
namespace := c.Metadata.Namespace