浏览代码

Readd channel on producer performance tool

The channel removed in da81d9c was actually necessary
to ensure that the final metrics are printed after the
periodic ones are all finished.
AJ Yoo 7 年之前
父节点
当前提交
6c7fa2cd19
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      tools/kafka-producer-performance/main.go

+ 3 - 1
tools/kafka-producer-performance/main.go

@@ -227,8 +227,10 @@ func main() {
 	}
 	}
 
 
 	// Print out metrics periodically.
 	// Print out metrics periodically.
+	done := make(chan struct{})
 	ctx, cancel := context.WithCancel(context.Background())
 	ctx, cancel := context.WithCancel(context.Background())
 	go func(ctx context.Context) {
 	go func(ctx context.Context) {
+		defer close(done)
 		t := time.Tick(5 * time.Second)
 		t := time.Tick(5 * time.Second)
 		for {
 		for {
 			select {
 			select {
@@ -250,7 +252,7 @@ func main() {
 	}
 	}
 
 
 	cancel()
 	cancel()
-	<-ctx.Done()
+	<-done
 
 
 	// Print final metrics.
 	// Print final metrics.
 	printMetrics(os.Stdout, config.MetricRegistry)
 	printMetrics(os.Stdout, config.MetricRegistry)