@@ -19,6 +19,7 @@ import (
19
19
"context"
20
20
"sync"
21
21
22
+ "github.com/conduitio/conduit/pkg/connector"
22
23
"github.com/conduitio/conduit/pkg/foundation/cerrors"
23
24
"github.com/conduitio/conduit/pkg/foundation/log"
24
25
"github.com/gammazero/deque"
@@ -122,6 +123,8 @@ func (n *DestinationAckerNode) worker(
122
123
errChan <- err
123
124
}
124
125
126
+ var acks []connector.DestinationAck
127
+
125
128
defer close (errChan )
126
129
for range signalChan {
127
130
// signal is received when a new message is in the queue
@@ -136,22 +139,29 @@ func (n *DestinationAckerNode) worker(
136
139
msg := n .queue .PopFront ()
137
140
n .m .Unlock ()
138
141
139
- acks , err := n .Destination .Ack (ctx )
140
- if err != nil {
141
- handleError (msg , cerrors .Errorf ("error while fetching acks: %w" , err ))
142
- return
143
- }
144
- for _ , ack := range acks {
145
- if ! bytes .Equal (msg .Record .Position , ack .Position ) {
146
- handleError (msg , cerrors .Errorf ("received unexpected ack, expected position %q but got %q" , msg .Record .Position , ack .Position ))
147
- return
148
- }
149
- err = n .handleAck (msg , ack .Error )
142
+ if len (acks ) == 0 {
143
+ // Ack can return multiple acks, store them and check the position
144
+ // for the current message
145
+ var err error
146
+ acks , err = n .Destination .Ack (ctx )
150
147
if err != nil {
151
- errChan <- err
148
+ handleError ( msg , cerrors . Errorf ( "error while fetching acks: %w" , err ))
152
149
return
153
150
}
154
151
}
152
+
153
+ ack := acks [0 ]
154
+ acks = acks [1 :]
155
+
156
+ if ! bytes .Equal (msg .Record .Position , ack .Position ) {
157
+ handleError (msg , cerrors .Errorf ("received unexpected ack, expected position %q but got %q" , msg .Record .Position , ack .Position ))
158
+ return
159
+ }
160
+ err := n .handleAck (msg , ack .Error )
161
+ if err != nil {
162
+ errChan <- err
163
+ return
164
+ }
155
165
}
156
166
}
157
167
}
0 commit comments