File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,8 +202,7 @@ func (c *testConsumer) etl(etlsBeforeQuit int) {
202202 }
203203 netls ++
204204
205- for iter := fetches .RecordIter (); ! iter .Done (); {
206- r := iter .Next ()
205+ for r := range fetches .RecordsAll () {
207206 keyNum , err := strconv .Atoi (string (r .Key ))
208207 if err != nil {
209208 c .errCh <- err
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package kgo
33import (
44 "context"
55 "errors"
6+ "iter"
67 "reflect"
78 "time"
89 "unsafe"
@@ -521,6 +522,19 @@ beforePartition:
521522 }
522523}
523524
525+ // RecordsAll returns a Go native iterator that yields the records in a fetch.
526+ //
527+ // Similarly to RecordIter(), the errors should be inspected separately.
528+ func (fs Fetches ) RecordsAll () iter.Seq [* Record ] {
529+ return func (yield func (* Record ) bool ) {
530+ for iter := fs .RecordIter (); ! iter .Done (); {
531+ if ! yield (iter .Next ()) {
532+ return
533+ }
534+ }
535+ }
536+ }
537+
524538// EachPartition calls fn for each partition in Fetches.
525539//
526540// Partitions are not visited in any specific order, and a topic may be visited
You can’t perform that action at this time.
0 commit comments