shibd commented on code in PR #1323:
URL: https://github.com/apache/pulsar-client-go/pull/1323#discussion_r1899549299
##########
pulsar/internal/connection_pool.go:
##########
@@ -141,6 +146,14 @@ func (p *connectionPool) GetConnections()
map[string]Connection {
return conns
}
+func (p *connectionPool) GenerateRoundRobinIndex() int32 {
+ cnt := atomic.AddInt32(&p.roundRobinCnt, 1)
+ if cnt < 0 {
+ cnt = -cnt
+ }
+ return cnt % p.maxConnectionsPerHost
+}
Review Comment:
> Could you make roundRobinCnt as uint32, so that we can simplify this
method. as the following:
Done
> I'm wondering why not just generate a random integer?
Here just keep original logic:
https://github.com/apache/pulsar-client-go/blob/ffba2a8fd2781f536bc03ec1408f82f6e4ea4d3a/pulsar/internal/connection_pool.go#L154-L161
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]