From 667188deee82d29fc5efe06e6af1e8a9e8a5ab08 Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Sat, 30 Mar 2024 01:04:36 -0700 Subject: [PATCH] Rename --- lib/iterator/iterator.go | 2 +- lib/iterator/iterator_test.go | 12 ++++++------ lib/kafkalib/writer.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/iterator/iterator.go b/lib/iterator/iterator.go index 0c7018a2..58712fc5 100644 --- a/lib/iterator/iterator.go +++ b/lib/iterator/iterator.go @@ -14,7 +14,7 @@ type batchIterator[T any] struct { } // Returns an iterater that splits a list of items into batches of the given step size. -func Batch[T any](items []T, step int) Iterator[[]T] { +func NewBatchIterator[T any](items []T, step int) Iterator[[]T] { return &batchIterator[T]{ items: items, index: 0, diff --git a/lib/iterator/iterator_test.go b/lib/iterator/iterator_test.go index de338bed..062b11e6 100644 --- a/lib/iterator/iterator_test.go +++ b/lib/iterator/iterator_test.go @@ -6,17 +6,17 @@ import ( "github.com/stretchr/testify/assert" ) -func TestBatch(t *testing.T) { +func TestBatchIterator(t *testing.T) { // length of items is 0 { - iter := Batch([]int{}, 2) + iter := NewBatchIterator([]int{}, 2) assert.False(t, iter.HasNext()) _, err := iter.Next() assert.ErrorContains(t, err, "iterator has finished") } // length of items is 1 { - iter := Batch([]int{1}, 2) + iter := NewBatchIterator([]int{1}, 2) assert.True(t, iter.HasNext()) { items, err := iter.Next() @@ -31,7 +31,7 @@ func TestBatch(t *testing.T) { } // n is 0 { - iter := Batch([]int{1, 2}, 0) + iter := NewBatchIterator([]int{1, 2}, 0) assert.True(t, iter.HasNext()) items, err := iter.Next() assert.NoError(t, err) @@ -43,7 +43,7 @@ func TestBatch(t *testing.T) { } // length of items is a multiple of n { - iter := Batch([]int{1, 2, 3, 4}, 2) + iter := NewBatchIterator([]int{1, 2, 3, 4}, 2) assert.True(t, iter.HasNext()) { items, err := iter.Next() @@ -64,7 +64,7 @@ func TestBatch(t *testing.T) { } // length of items is not a multiple of n { - iter := Batch([]int{1, 2, 3, 4, 5}, 2) + iter := NewBatchIterator([]int{1, 2, 3, 4, 5}, 2) assert.True(t, iter.HasNext()) { items, err := iter.Next() diff --git a/lib/kafkalib/writer.go b/lib/kafkalib/writer.go index 81e7f064..a14e7119 100644 --- a/lib/kafkalib/writer.go +++ b/lib/kafkalib/writer.go @@ -88,7 +88,7 @@ func (b *BatchWriter) WriteMessages(ctx context.Context, msgs []kafka.Message) e return nil } - iter := iterator.Batch(msgs, int(chunkSize)) + iter := iterator.NewBatchIterator(msgs, int(chunkSize)) for iter.HasNext() { tags := map[string]string{ "what": "error",