Skip to content

Commit 5254c93

Browse files
committedFeb 21, 2020
reduce duplicate rdy updation requests
1 parent d9600b3 commit 5254c93

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎consumer.go

+6
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,13 @@ func (r *Consumer) sendRDY(c *Conn, count int64) error {
981981
}
982982

983983
atomic.AddInt64(&r.totalRdyCount, count-c.RDY())
984+
985+
lastRDY := c.LastRDY()
984986
c.SetRDY(count)
987+
if count == lastRDY {
988+
return nil
989+
}
990+
985991
err := c.WriteCommand(Ready(int(count)))
986992
if err != nil {
987993
r.log(LogLevelError, "(%s) error sending RDY %d - %s", c.String(), count, err)

‎mock_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ func TestConsumerRequeueNoBackoff(t *testing.T) {
343343
"RDY 0",
344344
fmt.Sprintf("REQ %s 0", msgIDRequeueNoBackoff),
345345
"RDY 1",
346-
"RDY 1",
347346
fmt.Sprintf("FIN %s", msgIDGood),
348347
}
349348
if len(n.got) != len(expected) {

0 commit comments

Comments
 (0)
Please sign in to comment.