diff options
author | Valery Piashchynski <[email protected]> | 2020-12-16 21:00:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-16 21:00:23 +0300 |
commit | 466f138d91c495d5f13c7e0f6ac1c5b9ee3032d1 (patch) | |
tree | 3fcccb84dbd1bdfba85d5e4e93ca07ec77754b38 | |
parent | 6b767417b0d76b258648f9e7fd5984bb83a32d4e (diff) |
Remove goroutines from poller
-rw-r--r-- | plugins/reload/watcher.go | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/plugins/reload/watcher.go b/plugins/reload/watcher.go index 2ba02be2..fff11f32 100644 --- a/plugins/reload/watcher.go +++ b/plugins/reload/watcher.go @@ -361,38 +361,28 @@ func (w *Watcher) pollEvents(serviceName string, files map[string]os.FileInfo) { } } - wg := &sync.WaitGroup{} - wg.Add(2) - go func() { - defer wg.Done() - // Send all the remaining create and remove events. - for pth := range creates { - w.watcherConfigs[serviceName].Files[pth] = creates[pth] - w.log.Debug("file was added to watcher", "path", pth, "name", creates[pth].Name(), "size", creates[pth].Size()) - - w.Event <- Event{ - Path: pth, - Info: creates[pth], - service: serviceName, - } + // Send all the remaining create and remove events. + for pth := range creates { + w.watcherConfigs[serviceName].Files[pth] = creates[pth] + w.log.Debug("file was added to watcher", "path", pth, "name", creates[pth].Name(), "size", creates[pth].Size()) + + w.Event <- Event{ + Path: pth, + Info: creates[pth], + service: serviceName, } - }() + } - go func() { - defer wg.Done() - for pth := range removes { - delete(w.watcherConfigs[serviceName].Files, pth) - w.log.Debug("file was removed from watcher", "path", pth, "name", removes[pth].Name(), "size", removes[pth].Size()) + for pth := range removes { + delete(w.watcherConfigs[serviceName].Files, pth) + w.log.Debug("file was removed from watcher", "path", pth, "name", removes[pth].Name(), "size", removes[pth].Size()) - w.Event <- Event{ - Path: pth, - Info: removes[pth], - service: serviceName, - } + w.Event <- Event{ + Path: pth, + Info: removes[pth], + service: serviceName, } - }() - - wg.Wait() + } } func (w *Watcher) Stop() { |