Last active
April 14, 2022 07:26
-
-
Save BruceChen7/807bcecd4c684543a1cf4a6a917ce821 to your computer and use it in GitHub Desktop.
#golang#sync#waitgroup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
wg sync.WaitGroup | |
seriesSetChan = make(chan genericSeriesSet) | |
) | |
// Schedule all Selects for all queriers we know about. | |
for _, querier := range q.queriers { | |
wg.Add(1) | |
go func(qr genericQuerier) { | |
defer wg.Done() | |
// We need to sort for NewMergeSeriesSet to work. | |
seriesSetChan <- qr.Select(true, hints, matchers...) | |
}(querier) | |
} | |
go func() { | |
wg.Wait() | |
close(seriesSetChan) | |
}() | |
// 获取series | |
for r := range seriesSetChan { | |
seriesSets = append(seriesSets, r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment