Skip to content

Instantly share code, notes, and snippets.

@Jinnrry
Last active October 28, 2022 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jinnrry/d11a8c7dc74da724832206749afa12d8 to your computer and use it in GitHub Desktop.
Save Jinnrry/d11a8c7dc74da724832206749afa12d8 to your computer and use it in GitHub Desktop.
func (ms *metricSender) asyncSendMetricLoop() {
for i := 0; i < ms.goNum; i++ { // goNum变量应该是1
go ms.sendMetricFromChan(ms.metricInfoChans[i])
}
}
func (ms *metricSender) sendMetricFromChan(metricInfoChan chan *metricCell) {
defer func() {
ms.closeWG.Done()
if r := recover(); r != nil {
go ms.sendMetricFromChan(metricInfoChan)
}
}()
ms.closeWG.Add(1)
for {
mc, ok := <-metricInfoChan
if !ok {
return
}
Counter(ms.name, mc.tags)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment