File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ type BytesSource interface {
45
45
46
46
type BatchHandler func ([]interface {}) error
47
47
48
+ func NewBatch (batchSize int , pushHandler BatchHandler , flushHandler ... BatchHandler ) * Batch {
49
+ b := Batch {}
50
+ b .Init (batchSize , pushHandler , flushHandler ... )
51
+ return & b
52
+ }
53
+
48
54
func (b * Batch ) Init (batchSize int , pushHandler BatchHandler , flushHandler ... BatchHandler ) {
49
55
b .batchPosition = 0
50
56
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ import (
6
6
"testing"
7
7
)
8
8
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
+
9
18
func TestBatch_PushSingleItemBatch (t * testing.T ) {
10
19
b1 := Batch {}
11
20
singleItemBatchCallCount := 0
You can’t perform that action at this time.
0 commit comments