Add mutex to influx parser

This commit is contained in:
Daniel Nelson 2018-04-02 12:52:23 -07:00
parent 717347fce2
commit d247425e03
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package influx
import ( import (
"errors" "errors"
"fmt" "fmt"
"sync"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
) )
@ -32,6 +33,7 @@ func (e *ParseError) Error() string {
type Parser struct { type Parser struct {
DefaultTags map[string]string DefaultTags map[string]string
sync.Mutex
*machine *machine
handler *MetricHandler handler *MetricHandler
} }
@ -44,6 +46,8 @@ func NewParser(handler *MetricHandler) *Parser {
} }
func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) { func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
p.Lock()
defer p.Unlock()
metrics := make([]telegraf.Metric, 0) metrics := make([]telegraf.Metric, 0)
p.machine.SetData(input) p.machine.SetData(input)