From 76e2175159ac2ff4b26d2606f4d8f1d7a896c5cc Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Wed, 18 Jan 2017 18:22:16 +0100 Subject: Rename file --- manager.go | 39 +++++++++++++++++++++++++++++++++++++++ types.go | 48 ------------------------------------------------ 2 files changed, 39 insertions(+), 48 deletions(-) create mode 100644 manager.go delete mode 100644 types.go diff --git a/manager.go b/manager.go new file mode 100644 index 0000000..3fd2234 --- /dev/null +++ b/manager.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "sync" + + "github.com/Shugyousha/stasher/filter" + "github.com/Shugyousha/stasher/input" + "github.com/Shugyousha/stasher/output" + "github.com/Shugyousha/stasher/work" +) + +type Manager struct { + Input input.Input + Filter filter.Filter + Output output.Output +} + +func (m *Manager) Run() { + var wg sync.WaitGroup + + ic := m.Input.Start() + for w := range ic { + wg.Add(1) + + go func(w *work.Work) { + nw := m.Filter.Filter(w) + err := nw.Error() + if err != nil { + fmt.Printf("Got an error when processing Work: %q\n", err) + } + m.Output.Output(nw) + + wg.Done() + }(w) + } + + wg.Wait() +} diff --git a/types.go b/types.go deleted file mode 100644 index abd2658..0000000 --- a/types.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "fmt" - "sync" - - "github.com/Shugyousha/stasher/work" -) - -type Input interface { - Start() chan *work.Work -} - -type Filter interface { - Filter(*work.Work) *work.Work -} - -type Output interface { - Output(*work.Work) -} - -type Manager struct { - Input Input - Filter Filter - Output Output -} - -func (m *Manager) Run() { - var wg sync.WaitGroup - - ic := m.Input.Start() - for w := range ic { - wg.Add(1) - - go func(w *work.Work) { - nw := m.Filter.Filter(w) - err := nw.Error() - if err != nil { - fmt.Printf("Got an error when processing Work: %q\n", err) - } - m.Output.Output(nw) - - wg.Done() - }(w) - } - - wg.Wait() -} -- cgit v1.2.3