From 46cd4a21acf8bb0fac393a1f3604a6a5fd062954 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Thu, 14 Apr 2022 00:05:48 +0800 Subject: [PATCH] rename consumer -> reader --- agent/agent.go | 10 +++++----- agent/{consume.go => reader.go} | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) rename agent/{consume.go => reader.go} (94%) diff --git a/agent/agent.go b/agent/agent.go index 18c4a73..f6bed94 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -41,9 +41,9 @@ func (a *Agent) Start() { func (a *Agent) Stop() { log.Println("I! agent stopping") - for name := range InputConsumers { - InputConsumers[name].Instance.StopGoroutines() - close(InputConsumers[name].Queue) + for name := range InputReaders { + InputReaders[name].Instance.StopGoroutines() + close(InputReaders[name].Queue) } } @@ -84,7 +84,7 @@ func (a *Agent) startInputs() error { continue } - c := &Consumer{ + c := &Reader{ Instance: instance, Queue: make(chan *types.Sample, 1000000), } @@ -92,7 +92,7 @@ func (a *Agent) startInputs() error { log.Println("I! input:", name, "started") c.Start() - InputConsumers[name] = c + InputReaders[name] = c } return nil diff --git a/agent/consume.go b/agent/reader.go similarity index 94% rename from agent/consume.go rename to agent/reader.go index 8eff326..a34fbed 100644 --- a/agent/consume.go +++ b/agent/reader.go @@ -13,22 +13,22 @@ import ( "github.com/prometheus/prometheus/prompb" ) -type Consumer struct { +type Reader struct { Instance inputs.Input Queue chan *types.Sample } -var InputConsumers = map[string]*Consumer{} +var InputReaders = map[string]*Reader{} -func (c *Consumer) Start() { +func (c *Reader) Start() { // start consumer goroutines - go consume(c.Queue) + go read(c.Queue) // start collector goroutines c.Instance.StartGoroutines(c.Queue) } -func consume(queue chan *types.Sample) { +func read(queue chan *types.Sample) { batch := config.Config.WriterOpt.Batch if batch <= 0 { batch = 2000