all: Remove global events.Default (ref #4085) (#5886)

This commit is contained in:
Simon Frei
2019-08-15 16:29:37 +02:00
committed by GitHub
parent f6f696c6c5
commit b1c74860e8
46 changed files with 467 additions and 374 deletions

View File

@@ -125,19 +125,19 @@ func newAggregator(folderCfg config.FolderConfiguration, ctx context.Context) *a
return a
}
func Aggregate(in <-chan fs.Event, out chan<- []string, folderCfg config.FolderConfiguration, cfg config.Wrapper, ctx context.Context) {
func Aggregate(in <-chan fs.Event, out chan<- []string, folderCfg config.FolderConfiguration, cfg config.Wrapper, evLogger events.Logger, ctx context.Context) {
a := newAggregator(folderCfg, ctx)
// Necessary for unit tests where the backend is mocked
go a.mainLoop(in, out, cfg)
go a.mainLoop(in, out, cfg, evLogger)
}
func (a *aggregator) mainLoop(in <-chan fs.Event, out chan<- []string, cfg config.Wrapper) {
func (a *aggregator) mainLoop(in <-chan fs.Event, out chan<- []string, cfg config.Wrapper, evLogger events.Logger) {
a.notifyTimer = time.NewTimer(a.notifyDelay)
defer a.notifyTimer.Stop()
inProgressItemSubscription := events.Default.Subscribe(events.ItemStarted | events.ItemFinished)
defer events.Default.Unsubscribe(inProgressItemSubscription)
inProgressItemSubscription := evLogger.Subscribe(events.ItemStarted | events.ItemFinished)
defer inProgressItemSubscription.Unsubscribe()
cfg.Subscribe(a)
defer cfg.Unsubscribe(a)