use goroutine to send metrics to backend

This commit is contained in:
Ulric Qin 2022-04-21 11:07:56 +08:00
parent 9ba1c2c32d
commit a0c5f94017
1 changed files with 1 additions and 9 deletions

View File

@ -199,19 +199,11 @@ func (ws *WritersType) StartConsumer(ident string, ch chan *prompb.TimeSeries) {
// post post series to TSDB
// @Author: quzhihao
func (ws *WritersType) post(ident string, series []*prompb.TimeSeries) {
wg := sync.WaitGroup{}
wg.Add(len(ws.backends))
// maybe as backend hashstring
headers := map[string]string{"ident": ident}
for key := range ws.backends {
go func(key string) {
defer wg.Done()
ws.backends[key].Write(series, headers)
}(key)
go ws.backends[key].Write(series, headers)
}
wg.Wait()
}
func NewWriters() WritersType {