File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -71,14 +71,20 @@ type worker struct {
7171 flush chan chan bool
7272}
7373
74+ const (
75+ defaultBatchTimeoutSeconds = 20
76+ defaultBatchSize = 10000
77+ defaultBatchSizeBytes = 5 * 1024 * 1024 // 5 MiB
78+ )
79+
7480func New (client Client , opts ... Option ) (* BatchWriter , error ) {
7581 c := & BatchWriter {
7682 client : client ,
7783 workers : make (map [string ]* worker ),
7884 logger : zerolog .Nop (),
79- batchTimeout : writers . DefaultBatchTimeoutSeconds * time .Second ,
80- batchSize : writers . DefaultBatchSize ,
81- batchSizeBytes : writers . DefaultBatchSizeBytes ,
85+ batchTimeout : defaultBatchTimeoutSeconds * time .Second ,
86+ batchSize : defaultBatchSize ,
87+ batchSizeBytes : defaultBatchSizeBytes ,
8288 }
8389 for _ , opt := range opts {
8490 opt (c )
Original file line number Diff line number Diff line change @@ -46,12 +46,18 @@ func WithBatchSizeBytes(size int) Option {
4646 }
4747}
4848
49+ const (
50+ defaultBatchTimeoutSeconds = 20
51+ defaultBatchSize = 10000
52+ defaultBatchSizeBytes = 5 * 1024 * 1024 // 5 MiB
53+ )
54+
4955func New (client Client , opts ... Option ) (* MixedBatchWriter , error ) {
5056 c := & MixedBatchWriter {
5157 client : client ,
5258 logger : zerolog .Nop (),
53- batchSize : writers . DefaultBatchSize ,
54- batchSizeBytes : writers . DefaultBatchSizeBytes ,
59+ batchSize : defaultBatchSize ,
60+ batchSizeBytes : defaultBatchSizeBytes ,
5561 }
5662 for _ , opt := range opts {
5763 opt (c )
Original file line number Diff line number Diff line change @@ -101,14 +101,20 @@ func withTimerFn(timer timerFn) Option {
101101 }
102102}
103103
104+ const (
105+ defaultBatchTimeoutSeconds = 20
106+ defaultBatchSize = 10000
107+ defaultBatchSizeBytes = 5 * 1024 * 1024 // 5 MiB
108+ )
109+
104110func New (client Client , opts ... Option ) (* StreamingBatchWriter , error ) {
105111 c := & StreamingBatchWriter {
106112 client : client ,
107113 insertWorkers : make (map [string ]* streamingWorkerManager [* message.WriteInsert ]),
108114 logger : zerolog .Nop (),
109- batchTimeout : writers . DefaultBatchTimeoutSeconds * time .Second ,
110- batchSizeRows : writers . DefaultBatchSize ,
111- batchSizeBytes : writers . DefaultBatchSizeBytes ,
115+ batchTimeout : defaultBatchTimeoutSeconds * time .Second ,
116+ batchSizeRows : defaultBatchSize ,
117+ batchSizeBytes : defaultBatchSizeBytes ,
112118 timerFn : timer ,
113119 }
114120 for _ , opt := range opts {
Original file line number Diff line number Diff line change 99type Writer interface {
1010 Write (ctx context.Context , res <- chan message.WriteMessage ) error
1111}
12-
13- const (
14- DefaultBatchTimeoutSeconds = 20
15- DefaultBatchSize = 10000
16- DefaultBatchSizeBytes = 5 * 1024 * 1024 // 5 MiB
17- )
You can’t perform that action at this time.
0 commit comments