mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Do multiple org-hour records in parallel
This commit is contained in:
@@ -158,17 +158,31 @@ func main() {
|
||||
|
||||
totals := newSummary()
|
||||
|
||||
if recordsFile != "" {
|
||||
f, err := os.Open(recordsFile)
|
||||
checkFatal(err)
|
||||
defer f.Close()
|
||||
records := bufio.NewScanner(f)
|
||||
for records.Scan() {
|
||||
scanner.HandleRecord(context.Background(), orgs, records.Text())
|
||||
}
|
||||
checkFatal(records.Err())
|
||||
f, err := os.Open(recordsFile)
|
||||
checkFatal(err)
|
||||
defer f.Close()
|
||||
|
||||
// Create multiple goroutines reading off one queue of records to delete
|
||||
queue := make(chan string)
|
||||
var wait sync.WaitGroup
|
||||
wait.Add(scanner.segments)
|
||||
for i := 0; i < scanner.segments; i++ {
|
||||
go func() {
|
||||
for record := range queue {
|
||||
scanner.HandleRecord(context.Background(), orgs, record)
|
||||
}
|
||||
wait.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
records := bufio.NewScanner(f)
|
||||
for records.Scan() {
|
||||
queue <- records.Text()
|
||||
}
|
||||
checkFatal(records.Err())
|
||||
close(queue)
|
||||
wait.Wait()
|
||||
|
||||
fmt.Printf("\n")
|
||||
totals.print()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user