mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
Clear workerInput channel after done event
This commit is contained in:
parent
8c73095548
commit
c2d4272fdf
@ -50,7 +50,18 @@ func (r *RedfishReceiver) Start() {
|
|||||||
// Connect to redfish service
|
// Connect to redfish service
|
||||||
c, err := gofish.Connect(clientConfig.gofish)
|
c, err := gofish.Connect(clientConfig.gofish)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("readPowerMetric: gofish.Connect(...) failed: %v", err)
|
c := struct {
|
||||||
|
Username string
|
||||||
|
Endpoint string
|
||||||
|
BasicAuth bool
|
||||||
|
Insecure bool
|
||||||
|
}{
|
||||||
|
Username: clientConfig.gofish.Username,
|
||||||
|
Endpoint: clientConfig.gofish.Endpoint,
|
||||||
|
BasicAuth: clientConfig.gofish.BasicAuth,
|
||||||
|
Insecure: clientConfig.gofish.Insecure,
|
||||||
|
}
|
||||||
|
return fmt.Errorf("readPowerMetric: gofish.Connect(%+v) failed: %v", c, err)
|
||||||
}
|
}
|
||||||
defer c.Logout()
|
defer c.Logout()
|
||||||
|
|
||||||
@ -146,18 +157,19 @@ func (r *RedfishReceiver) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Distribute client configs to workers
|
// Distribute client configs to workers
|
||||||
clientConfigLoop:
|
|
||||||
for i := range r.config.ClientConfigs {
|
for i := range r.config.ClientConfigs {
|
||||||
// Check done channel status
|
// Check done channel status
|
||||||
select {
|
select {
|
||||||
case _, ok := <-r.done:
|
case workerInput <- i:
|
||||||
if !ok {
|
case <-r.done:
|
||||||
break clientConfigLoop
|
// process done event
|
||||||
|
// Stop workers, clear channel and wait for all workers to finish
|
||||||
|
close(workerInput)
|
||||||
|
for range workerInput {
|
||||||
}
|
}
|
||||||
default:
|
workerWaitGroup.Wait()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
workerInput <- i
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop workers and wait for all workers to finish
|
// Stop workers and wait for all workers to finish
|
||||||
|
Loading…
Reference in New Issue
Block a user