mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2026-02-13 22:51:45 +01:00
Goroutine creation can be simplified using WaitGroup.Go (modernize)
This commit is contained in:
@@ -123,9 +123,7 @@ func (cm *collectorManager) Start() {
|
|||||||
tick := make(chan time.Time)
|
tick := make(chan time.Time)
|
||||||
cm.ticker.AddChannel(tick)
|
cm.ticker.AddChannel(tick)
|
||||||
|
|
||||||
cm.wg.Add(1)
|
cm.wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer cm.wg.Done()
|
|
||||||
// Collector manager is done
|
// Collector manager is done
|
||||||
done := func() {
|
done := func() {
|
||||||
// close all metric collectors
|
// close all metric collectors
|
||||||
@@ -180,7 +178,7 @@ func (cm *collectorManager) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
|
|
||||||
// Collector manager is started
|
// Collector manager is started
|
||||||
cclog.ComponentDebug("CollectorManager", "STARTED")
|
cclog.ComponentDebug("CollectorManager", "STARTED")
|
||||||
|
|||||||
@@ -102,9 +102,7 @@ func (c *metricCache) Start() {
|
|||||||
return oldPeriod
|
return oldPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
c.wg.Add(1)
|
c.wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer c.wg.Done()
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-c.done:
|
case <-c.done:
|
||||||
@@ -124,7 +122,7 @@ func (c *metricCache) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
cclog.ComponentDebug("MetricCache", "START")
|
cclog.ComponentDebug("MetricCache", "START")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -291,9 +291,7 @@ func (r *metricRouter) Start() {
|
|||||||
r.cache.Start()
|
r.cache.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
r.wg.Add(1)
|
r.wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer r.wg.Done()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@@ -324,7 +322,7 @@ func (r *metricRouter) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
cclog.ComponentDebug("MetricRouter", "STARTED")
|
cclog.ComponentDebug("MetricRouter", "STARTED")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user