Skip to content

Commit d11dd56

Browse files
authored
fix(writers): Don't export defaults (#1013)
1 parent e290234 commit d11dd56

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

writers/batchwriter/batchwriter.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
7480
func 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)

writers/mixedbatchwriter/mixedbatchwriter.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
4955
func 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)

writers/streamingbatchwriter/streamingbatchwriter.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
104110
func 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 {

writers/writers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@ import (
99
type 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-
)

0 commit comments

Comments
 (0)