diff --git a/influxdb3/batching/batcher.go b/influxdb3/batching/batcher.go index 02d91e1..8e01f2a 100644 --- a/influxdb3/batching/batcher.go +++ b/influxdb3/batching/batcher.go @@ -103,13 +103,13 @@ func NewBatcher(options ...Option) *Batcher { return b } -// Add a metric to the batcher and call the given callbacks if any -func (b *Batcher) Add(p *influxdb3.Point) { +// Add metric(s) to the batcher and call the given callbacks if any +func (b *Batcher) Add(p ...*influxdb3.Point) { b.Lock() defer b.Unlock() // Add the point - b.points = append(b.points, p) + b.points = append(b.points, p...) // Call callbacks if a new batch is ready if b.isReady() { diff --git a/influxdb3/batching/batcher_test.go b/influxdb3/batching/batcher_test.go index a2e82a7..8403005 100644 --- a/influxdb3/batching/batcher_test.go +++ b/influxdb3/batching/batcher_test.go @@ -79,9 +79,8 @@ func TestReady(t *testing.T) { WithSize(batchSize), ) - for range batchSize { - b.Add(&influxdb3.Point{}) - } + points := []*influxdb3.Point{{}, {}, {}, {}, {}} + b.Add(points...) assert.True(t, b.Ready(), "Batcher should be ready when the batch size is reached") } @@ -115,7 +114,7 @@ func TestPartialEmit(t *testing.T) { }), ) - b.Add(&influxdb3.Point{}) + b.Add(&influxdb3.Point{}, &influxdb3.Point{}) b.Add(&influxdb3.Point{}) points := b.Emit()