use AddError everywhere (#2372)

This commit is contained in:
Patrick Hemmer
2017-04-24 14:13:26 -04:00
committed by Daniel Nelson
parent 801f6cb8a0
commit 06baf7cf78
95 changed files with 341 additions and 531 deletions

View File

@@ -32,7 +32,6 @@ import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -66,17 +65,16 @@ func (n *NSQ) Description() string {
func (n *NSQ) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
errChan := errchan.New(len(n.Endpoints))
for _, e := range n.Endpoints {
wg.Add(1)
go func(e string) {
defer wg.Done()
errChan.C <- n.gatherEndpoint(e, acc)
acc.AddError(n.gatherEndpoint(e, acc))
}(e)
}
wg.Wait()
return errChan.Error()
return nil
}
var tr = &http.Transport{

View File

@@ -24,7 +24,7 @@ func TestNSQStats(t *testing.T) {
}
var acc testutil.Accumulator
err := n.Gather(&acc)
err := acc.GatherError(n.Gather)
require.NoError(t, err)
u, err := url.Parse(ts.URL)