diff options
-rw-r--r-- | manager.go | 7 | ||||
-rw-r--r-- | output/http/http.go | 4 | ||||
-rw-r--r-- | output/outputinterface.go | 2 | ||||
-rw-r--r-- | output/stdout/stdout.go | 5 |
4 files changed, 12 insertions, 6 deletions
@@ -27,9 +27,12 @@ func (m *Manager) Run() { nw := m.Filter.Filter(w) err := nw.Error() if err != nil { - fmt.Printf("Got an error when processing Work: %q\n", err) + fmt.Printf("Got an error when filtering Work: %q\n", err) + } + err = m.Output.Output(nw) + if err != nil { + fmt.Printf("Got an error when outputting Work: %q\n", err) } - m.Output.Output(nw) wg.Done() }(w) diff --git a/output/http/http.go b/output/http/http.go index 3ea603c..158f091 100644 --- a/output/http/http.go +++ b/output/http/http.go @@ -22,9 +22,11 @@ func New(kv map[string]string) output.Output { return &HttpOutput{url: url} } -func (h *HttpOutput) Output(w *work.Work) { +func (h *HttpOutput) Output(w *work.Work) error { _, err := http.Post(h.url, "application/json", bytes.NewReader(w.Data)) if err != nil { w.Err = err } + + return err } diff --git a/output/outputinterface.go b/output/outputinterface.go index 8f1137a..385fe4e 100644 --- a/output/outputinterface.go +++ b/output/outputinterface.go @@ -3,5 +3,5 @@ package output import "github.com/Shugyousha/stasher/work" type Output interface { - Output(*work.Work) + Output(*work.Work) error } diff --git a/output/stdout/stdout.go b/output/stdout/stdout.go index 9d66581..f3e4f57 100644 --- a/output/stdout/stdout.go +++ b/output/stdout/stdout.go @@ -19,6 +19,7 @@ func New(map[string]string) output.Output { return &StdoutOutput{} } -func (o *StdoutOutput) Output(w *work.Work) { - fmt.Printf("%s\n", w.Data) +func (o *StdoutOutput) Output(w *work.Work) error { + _, err := fmt.Printf("%s\n", w.Data) + return err } |