inlet/core: correctly close new ticker on stop

This commit is contained in:
Vincent Bernat
2022-08-10 17:20:04 +02:00
parent efbaed2866
commit 17eb5529cf
2 changed files with 4 additions and 2 deletions

View File

@@ -80,6 +80,7 @@ func (c *Component) Start() error {
errLogger := c.r.Sample(reporter.BurstSampler(time.Minute, 10))
c.t.Go(func() error {
defer ticker.Stop()
ctx := c.t.Context(context.Background())
templateCount := 0
transmit := func(kind string, payloads <-chan []byte) {
@@ -93,7 +94,6 @@ func (c *Component) Start() error {
}
}
}
defer ticker.Stop()
for {
select {
case <-c.t.Dying():

View File

@@ -33,7 +33,9 @@ func (c *Component) FlowsHTTPHandler(gc *gin.Context) {
// Flush from time to time
var tickerChan <-chan time.Time
tickerChan = time.NewTicker(c.httpFlowFlushDelay).C
ticker := time.NewTicker(c.httpFlowFlushDelay)
tickerChan = ticker.C
defer ticker.Stop()
for {
select {