File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ type BytesSource interface {
4545
4646type BatchHandler func ([]interface {}) error
4747
48+ func NewBatch (batchSize int , pushHandler BatchHandler , flushHandler ... BatchHandler ) * Batch {
49+ b := Batch {}
50+ b .Init (batchSize , pushHandler , flushHandler ... )
51+ return & b
52+ }
53+
4854func (b * Batch ) Init (batchSize int , pushHandler BatchHandler , flushHandler ... BatchHandler ) {
4955 b .batchPosition = 0
5056
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ import (
66 "testing"
77)
88
9+ func TestNewBatch (t * testing.T ) {
10+ b1 := NewBatch (100 , func (i []interface {}) error {
11+ return nil
12+ })
13+ if b1 == nil {
14+ t .Fatal ("new batch is nil" )
15+ }
16+ }
17+
918func TestBatch_PushSingleItemBatch (t * testing.T ) {
1019 b1 := Batch {}
1120 singleItemBatchCallCount := 0
You can’t perform that action at this time.
0 commit comments