Skip to content

Commit 7cc3203

Browse files
authored
fix(client): fix auto_flush_interval units in LineSenderFromConf (#40)
1 parent 857a531 commit 7cc3203

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

conf_parse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func confFromStr(conf string) (*lineSenderConfig, error) {
116116
if err != nil {
117117
return nil, NewInvalidConfigStrError("invalid %s value, %q is not a valid int", k, v)
118118
}
119-
senderConf.autoFlushInterval = time.Duration(parsedVal)
119+
senderConf.autoFlushInterval = time.Duration(parsedVal) * time.Millisecond
120120
case "min_throughput", "init_buf_size", "max_buf_size":
121121
parsedVal, err := strconv.Atoi(v)
122122
if err != nil {
@@ -138,7 +138,7 @@ func confFromStr(conf string) (*lineSenderConfig, error) {
138138
if err != nil {
139139
return nil, NewInvalidConfigStrError("invalid %s value, %q is not a valid int", k, v)
140140
}
141-
timeoutDur := time.Duration(timeout * int(time.Millisecond))
141+
timeoutDur := time.Duration(timeout) * time.Millisecond
142142

143143
switch k {
144144
case "request_timeout":

conf_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func TestHappyCasesFromConf(t *testing.T) {
400400
qdb.WithHttp(),
401401
qdb.WithAddress(addr),
402402
qdb.WithAutoFlushRows(100),
403-
qdb.WithAutoFlushInterval(1000),
403+
qdb.WithAutoFlushInterval(1000 * time.Millisecond),
404404
},
405405
},
406406
{
@@ -422,7 +422,7 @@ func TestHappyCasesFromConf(t *testing.T) {
422422
qdb.WithHttp(),
423423
qdb.WithAddress(addr),
424424
qdb.WithAutoFlushRows(0),
425-
qdb.WithAutoFlushInterval(1000),
425+
qdb.WithAutoFlushInterval(1000 * time.Millisecond),
426426
},
427427
},
428428
}

http_sender_test.go

+4-14
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,8 @@ func TestTimeBasedAutoFlushWithRowBasedFlushDisabled(t *testing.T) {
462462
assert.NoError(t, err)
463463
defer srv.Close()
464464

465-
sender, err := qdb.NewLineSender(
466-
ctx,
467-
qdb.WithHttp(),
468-
qdb.WithAddress(srv.Addr()),
469-
qdb.WithAutoFlushRows(0),
470-
qdb.WithAutoFlushInterval(autoFlushInterval),
471-
)
465+
sender, err := qdb.LineSenderFromConf(ctx,
466+
fmt.Sprintf("http::addr=%s;auto_flush_rows=off;auto_flush_interval=%d;", srv.Addr(), autoFlushInterval.Milliseconds()))
472467
assert.NoError(t, err)
473468
defer sender.Close(ctx)
474469

@@ -494,13 +489,8 @@ func TestRowBasedAutoFlushWithTimeBasedFlushDisabled(t *testing.T) {
494489
assert.NoError(t, err)
495490
defer srv.Close()
496491

497-
sender, err := qdb.NewLineSender(
498-
ctx,
499-
qdb.WithHttp(),
500-
qdb.WithAddress(srv.Addr()),
501-
qdb.WithAutoFlushRows(autoFlushRows),
502-
qdb.WithAutoFlushInterval(0),
503-
)
492+
sender, err := qdb.LineSenderFromConf(ctx,
493+
fmt.Sprintf("http::addr=%s;auto_flush_rows=%d;auto_flush_interval=off;", srv.Addr(), autoFlushRows))
504494
assert.NoError(t, err)
505495
defer sender.Close(ctx)
506496

sender.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ func LineSenderFromEnv(ctx context.Context) (LineSender, error) {
441441
// token: bearer token auth (used instead of basic authentication)
442442
// auto_flush: determines if auto-flushing is enabled (values "on" or "off", defaults to "on")
443443
// auto_flush_rows: auto-flushing is triggered above this row count (defaults to 75000). If set, explicitly implies auto_flush=on. Set to 'off' to disable.
444-
//auto_flush_interval auto-flushing is triggered above this time (defaults to 1000 milliseconds). If set, explicitly implies auto_flush=on. Set to 'off' to disable.
444+
// auto_flush_interval: auto-flushing is triggered above this time, in milliseconds (defaults to 1000 milliseconds). If set, explicitly implies auto_flush=on. Set to 'off' to disable.
445445
// request_min_throughput: bytes per second, used to calculate each request's timeout (defaults to 100KiB/s)
446446
// request_timeout: minimum request timeout in milliseconds (defaults to 10 seconds)
447447
// retry_timeout: cumulative maximum millisecond duration spent in retries (defaults to 10 seconds)

0 commit comments

Comments
 (0)