You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/01 15:44:39 UTC

[GitHub] [pulsar-client-go] zzzming commented on a diff in pull request #799: [issue #752] replace go-rate rate limiter with a buffered channel implementation

zzzming commented on code in PR #799:
URL: https://github.com/apache/pulsar-client-go/pull/799#discussion_r912071823


##########
perf/perf-producer.go:
##########
@@ -101,25 +100,26 @@ func produce(produceArgs *ProduceArgs, stop <-chan struct{}) {
 	payload := make([]byte, produceArgs.MessageSize)
 
 	ch := make(chan float64)
-
-	go func(stopCh <-chan struct{}) {
-		var rateLimiter *rate.RateLimiter
-		if produceArgs.Rate > 0 {
-			rateLimiter = rate.New(produceArgs.Rate, time.Second)
+	rateLimitCh := make(chan time.Time, produceArgs.Rate)

Review Comment:
   The buffer size is the rate per second. It is a leaky bucket rate limiter implementation. So the channel buffer should hold the same number of rate allowed. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org