Use errchan in redis input plugin

this may address, or at least log issue #1462
This commit is contained in:
Cameron Sparr 2016-07-18 17:26:44 +01:00
parent dabb6f5466
commit b58cd78c79
1 changed files with 4 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
@ -96,9 +97,7 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error {
} }
var wg sync.WaitGroup var wg sync.WaitGroup
errChan := errchan.New(len(r.Servers))
var outerr error
for _, serv := range r.Servers { for _, serv := range r.Servers {
if !strings.HasPrefix(serv, "tcp://") || !strings.HasPrefix(serv, "unix://") { if !strings.HasPrefix(serv, "tcp://") || !strings.HasPrefix(serv, "unix://") {
serv = "tcp://" + serv serv = "tcp://" + serv
@ -123,13 +122,12 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error {
wg.Add(1) wg.Add(1)
go func(serv string) { go func(serv string) {
defer wg.Done() defer wg.Done()
outerr = r.gatherServer(u, acc) errChan.C <- r.gatherServer(u, acc)
}(serv) }(serv)
} }
wg.Wait() wg.Wait()
return errChan.Error()
return outerr
} }
func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error { func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {