Skip to content

Commit fcec48d

Browse files
committed
simplify the code further
1 parent 22c17c2 commit fcec48d

7 files changed

Lines changed: 746 additions & 401 deletions

File tree

‎cmd/consumer/conductor/conductor.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,17 @@ func (c *Conductor) run(ctx context.Context, tasks <-chan *decode.Future, w *wri
150150
lastLogTime := time.Now()
151151
ticker := time.NewTicker(progressLogInterval)
152152
defer ticker.Stop()
153+
writerDone := w.Done()
153154

154155
for {
155156
select {
156157
case <-ctx.Done():
157158
return context.Cause(ctx)
158159
case <-ticker.C:
159160
c.logProgress(w, inBytes, &lastLogTime, &lastInBytes, &lastOutRows)
161+
case <-writerDone:
162+
w.SyncCheckpoint()
163+
c.observeCheckpoint(c.confirmCheckpoint(w.Checkpoint()))
160164
case future := <-tasks:
161165
if err := future.Ready(ctx); err != nil {
162166
return err
@@ -185,6 +189,7 @@ func (c *Conductor) logProgress(w *writer.Writer, inBytes int64, lastLogTime *ti
185189
}
186190

187191
outRows, droppedRows := w.Stats()
192+
inFlightEvents, inFlightBytes := w.InFlight()
188193
checkpoint := w.Checkpoint()
189194
rowsPerSec := float64(outRows-*lastOutRows) / elapsed
190195
bytesPerSec := float64(inBytes-*lastInBytes) / elapsed
@@ -205,6 +210,11 @@ func (c *Conductor) logProgress(w *writer.Writer, inBytes int64, lastLogTime *ti
205210
zap.Int("pendingDDL", len(c.pendingDDL)),
206211
zap.Int("pendingDecode", c.waitingCount),
207212
}
213+
if inFlightEvents != 0 {
214+
fields = append(fields,
215+
zap.Int("inFlightEvents", inFlightEvents),
216+
zap.Int64("inFlightBytes", inFlightBytes))
217+
}
208218
if droppedRows != 0 {
209219
fields = append(fields, zap.Int64("droppedRows", droppedRows))
210220
}

0 commit comments

Comments
 (0)