rename consumer -> reader

This commit is contained in:
Ulric Qin 2022-04-14 00:05:48 +08:00
parent 6ae0309cf6
commit 46cd4a21ac
2 changed files with 10 additions and 10 deletions

View File

@ -41,9 +41,9 @@ func (a *Agent) Start() {
func (a *Agent) Stop() { func (a *Agent) Stop() {
log.Println("I! agent stopping") log.Println("I! agent stopping")
for name := range InputConsumers { for name := range InputReaders {
InputConsumers[name].Instance.StopGoroutines() InputReaders[name].Instance.StopGoroutines()
close(InputConsumers[name].Queue) close(InputReaders[name].Queue)
} }
} }
@ -84,7 +84,7 @@ func (a *Agent) startInputs() error {
continue continue
} }
c := &Consumer{ c := &Reader{
Instance: instance, Instance: instance,
Queue: make(chan *types.Sample, 1000000), Queue: make(chan *types.Sample, 1000000),
} }
@ -92,7 +92,7 @@ func (a *Agent) startInputs() error {
log.Println("I! input:", name, "started") log.Println("I! input:", name, "started")
c.Start() c.Start()
InputConsumers[name] = c InputReaders[name] = c
} }
return nil return nil

View File

@ -13,22 +13,22 @@ import (
"github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/prompb"
) )
type Consumer struct { type Reader struct {
Instance inputs.Input Instance inputs.Input
Queue chan *types.Sample 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 // start consumer goroutines
go consume(c.Queue) go read(c.Queue)
// start collector goroutines // start collector goroutines
c.Instance.StartGoroutines(c.Queue) c.Instance.StartGoroutines(c.Queue)
} }
func consume(queue chan *types.Sample) { func read(queue chan *types.Sample) {
batch := config.Config.WriterOpt.Batch batch := config.Config.WriterOpt.Batch
if batch <= 0 { if batch <= 0 {
batch = 2000 batch = 2000