Copilot commented on code in PR #1385:
URL: https://github.com/apache/pulsar-client-go/pull/1385#discussion_r2194235740
##########
pulsar/negative_backoff_policy.go:
##########
@@ -41,9 +41,11 @@ func (nbp *defaultNackBackoffPolicy) Next(redeliveryCount
uint32) time.Duration
minNackTime := 1 * time.Second // 1sec
maxNackTime := 10 * time.Minute // 10min
- if redeliveryCount < 0 {
- return minNackTime
+ backoff := float64(minNackTime << redeliveryCount)
+ if backoff == 0 {
+ // Overflow so we assign the maximum value of the backoff.
+ backoff = float64(maxNackTime)
}
- return
time.Duration(math.Min(math.Abs(float64(minNackTime<<redeliveryCount)),
float64(maxNackTime)))
+ return time.Duration(math.Min(math.Abs(backoff), float64(maxNackTime)))
Review Comment:
[nitpick] The call to `math.Abs` is redundant because `backoff` is always
non-negative. You can simplify to `math.Min(backoff, float64(maxNackTime))`.
```suggestion
return time.Duration(math.Min(backoff, float64(maxNackTime)))
```
--
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]