Skip to content

Commit

Permalink
fetches: add EachRecord
Browse files Browse the repository at this point in the history
to complete EachPartition and EachTopic, we add EachRecord solely for
people that prefer a functional callback rather than an iterator.
  • Loading branch information
twmb committed May 11, 2021
1 parent aea185e commit 231d0e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/kgo/record_and_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ func (fs Fetches) EachTopic(fn func(FetchTopic)) {
}
}

// EachRecord calls fn for each record in Fetches.
//
// This is very similar to using a record iter, and is solely a convenience
// function depending on which style you prefer.
func (fs Fetches) EachRecord(fn func(*Record)) {
for iter := fs.RecordIter(); !iter.Done(); {
fn(iter.Next())
}
}

// FetchTopicPartition is similar to FetchTopic, but for an individual
// partition.
type FetchTopicPartition struct {
Expand Down

0 comments on commit 231d0e4

Please sign in to comment.