Skip to content

Commit 27cecb6

Browse files
authored
fix(client): fix request_min_throughput config parameter name (#43)
Also fixes godoc formatting for LineSenderFromConf
1 parent 831daba commit 27cecb6

File tree

6 files changed

+49
-31
lines changed

6 files changed

+49
-31
lines changed

conf_parse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ func confFromStr(conf string) (*lineSenderConfig, error) {
117117
return nil, NewInvalidConfigStrError("invalid %s value, %q is not a valid int", k, v)
118118
}
119119
senderConf.autoFlushInterval = time.Duration(parsedVal) * time.Millisecond
120-
case "min_throughput", "init_buf_size", "max_buf_size":
120+
case "request_min_throughput", "init_buf_size", "max_buf_size":
121121
parsedVal, err := strconv.Atoi(v)
122122
if err != nil {
123123
return nil, NewInvalidConfigStrError("invalid %s value, %q is not a valid int", k, v)
124124
}
125125

126126
switch k {
127-
case "min_throughput":
127+
case "request_min_throughput":
128128
senderConf.minThroughput = parsedVal
129129
case "init_buf_size":
130130
senderConf.initBufSize = parsedVal

conf_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,26 @@ func TestParserHappyCases(t *testing.T) {
118118
},
119119
},
120120
{
121-
name: "https with min_throughput",
122-
config: fmt.Sprintf("https::addr=%s;min_throughput=%d;", addr, min_throughput),
121+
name: "https with request_min_throughput",
122+
config: fmt.Sprintf("https::addr=%s;request_min_throughput=%d;", addr, min_throughput),
123123
expected: qdb.ConfigData{
124124
Schema: "https",
125125
KeyValuePairs: map[string]string{
126-
"addr": addr,
127-
"min_throughput": fmt.Sprintf("%d", min_throughput),
126+
"addr": addr,
127+
"request_min_throughput": fmt.Sprintf("%d", min_throughput),
128128
},
129129
},
130130
},
131131
{
132-
name: "https with min_throughput, init_buf_size and tls_verify=unsafe_off",
133-
config: fmt.Sprintf("https::addr=%s;min_throughput=%d;init_buf_size=%d;tls_verify=unsafe_off;", addr, min_throughput, 1024),
132+
name: "https with request_min_throughput, init_buf_size and tls_verify=unsafe_off",
133+
config: fmt.Sprintf("https::addr=%s;request_min_throughput=%d;init_buf_size=%d;tls_verify=unsafe_off;", addr, min_throughput, 1024),
134134
expected: qdb.ConfigData{
135135
Schema: "https",
136136
KeyValuePairs: map[string]string{
137-
"addr": addr,
138-
"min_throughput": fmt.Sprintf("%d", min_throughput),
139-
"init_buf_size": "1024",
140-
"tls_verify": "unsafe_off",
137+
"addr": addr,
138+
"request_min_throughput": fmt.Sprintf("%d", min_throughput),
139+
"init_buf_size": "1024",
140+
"tls_verify": "unsafe_off",
141141
},
142142
},
143143
},
@@ -153,16 +153,16 @@ func TestParserHappyCases(t *testing.T) {
153153
},
154154
},
155155
{
156-
name: "http with min_throughput, request_timeout, and retry_timeout",
157-
config: fmt.Sprintf("http::addr=%s;min_throughput=%d;request_timeout=%d;retry_timeout=%d;",
156+
name: "http with request_min_throughput, request_timeout, and retry_timeout",
157+
config: fmt.Sprintf("http::addr=%s;request_min_throughput=%d;request_timeout=%d;retry_timeout=%d;",
158158
addr, min_throughput, request_timeout.Milliseconds(), retry_timeout.Milliseconds()),
159159
expected: qdb.ConfigData{
160160
Schema: "http",
161161
KeyValuePairs: map[string]string{
162-
"addr": addr,
163-
"min_throughput": fmt.Sprintf("%d", min_throughput),
164-
"request_timeout": fmt.Sprintf("%d", request_timeout.Milliseconds()),
165-
"retry_timeout": fmt.Sprintf("%d", retry_timeout.Milliseconds()),
162+
"addr": addr,
163+
"request_min_throughput": fmt.Sprintf("%d", min_throughput),
164+
"request_timeout": fmt.Sprintf("%d", request_timeout.Milliseconds()),
165+
"retry_timeout": fmt.Sprintf("%d", retry_timeout.Milliseconds()),
166166
},
167167
},
168168
},
@@ -373,8 +373,8 @@ func TestHappyCasesFromConf(t *testing.T) {
373373
},
374374
},
375375
{
376-
name: "min_throughput",
377-
config: fmt.Sprintf("http::addr=%s;min_throughput=%d;",
376+
name: "request_min_throughput",
377+
config: fmt.Sprintf("http::addr=%s;request_min_throughput=%d;",
378378
addr, minThroughput),
379379
expectedOpts: []qdb.LineSenderOption{
380380
qdb.WithHttp(),

http_sender.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (s *httpLineSender) makeRequest(ctx context.Context) (bool, error) {
355355
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", s.token))
356356
}
357357

358-
// reqTimeout = ( request.len() / min_throughput ) + request_timeout
358+
// reqTimeout = ( request.len() / request_min_throughput ) + request_timeout
359359
// nb: conversion from int to time.Duration is in milliseconds
360360
reqTimeout := time.Duration(s.buf.Len()/s.minThroughputBytesPerSecond)*time.Second + s.requestTimeout
361361
reqCtx, cancel := context.WithTimeout(ctx, reqTimeout)

http_sender_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ func TestHttpHappyCasesFromConf(t *testing.T) {
6666
addr, pass, user),
6767
},
6868
{
69-
name: "min_throughput",
70-
config: fmt.Sprintf("http::addr=%s;min_throughput=%d;",
69+
name: "request_min_throughput",
70+
config: fmt.Sprintf("http::addr=%s;request_min_throughput=%d;",
7171
addr, min_throughput),
7272
},
7373
{
@@ -150,7 +150,7 @@ func TestHttpPathologicalCasesFromConf(t *testing.T) {
150150
},
151151
{
152152
name: "negative min throughput",
153-
config: "http::min_throughput=-1;",
153+
config: "http::request_min_throughput=-1;",
154154
expectedErr: "min throughput is negative",
155155
},
156156
{

sender.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ func WithBearerToken(token string) LineSenderOption {
263263
}
264264
}
265265

266-
// WithRequestTimeout is used in combination with min_throughput
266+
// WithRequestTimeout is used in combination with request_min_throughput
267267
// to set the timeout of an ILP request. Defaults to 10 seconds.
268268
//
269-
// timeout = (request.len() / min_throughput) + request_timeout
269+
// timeout = (request.len() / request_min_throughput) + request_timeout
270270
//
271271
// Only available for the HTTP sender.
272272
func WithRequestTimeout(timeout time.Duration) LineSenderOption {
@@ -278,7 +278,7 @@ func WithRequestTimeout(timeout time.Duration) LineSenderOption {
278278
// WithMinThroughput is used in combination with request_timeout
279279
// to set the timeout of an ILP request. Defaults to 100KiB/s.
280280
//
281-
// timeout = (request.len() / min_throughput) + request_timeout
281+
// timeout = (request.len() / request_min_throughput) + request_timeout
282282
//
283283
// Only available for the HTTP sender.
284284
func WithMinThroughput(bytesPerSecond int) LineSenderOption {
@@ -429,27 +429,45 @@ func LineSenderFromEnv(ctx context.Context) (LineSender, error) {
429429
//
430430
// Options:
431431
// http(s) and tcp(s):
432+
//
432433
// -------------------
434+
//
433435
// addr: hostname/port of QuestDB endpoint
436+
//
434437
// init_buf_size: initial growable ILP buffer size in bytes (defaults to 128KiB)
438+
//
435439
// tls_verify: determines if TLS certificates should be validated (defaults to "on", can be set to "unsafe_off")
436440
//
437441
// http(s)-only
442+
//
438443
// ------------
444+
//
439445
// username: for basic authentication
446+
//
440447
// password: for basic authentication
448+
//
441449
// token: bearer token auth (used instead of basic authentication)
450+
//
442451
// auto_flush: determines if auto-flushing is enabled (values "on" or "off", defaults to "on")
452+
//
443453
// 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.
454+
//
444455
// 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.
456+
//
445457
// request_min_throughput: bytes per second, used to calculate each request's timeout (defaults to 100KiB/s)
458+
//
446459
// request_timeout: minimum request timeout in milliseconds (defaults to 10 seconds)
460+
//
447461
// retry_timeout: cumulative maximum millisecond duration spent in retries (defaults to 10 seconds)
462+
//
448463
// max_buf_size: buffer growth limit in bytes. Client errors if breached (default is 100MiB)
449464
//
450465
// tcp(s)-only
466+
//
451467
// -----------
468+
//
452469
// username: KID (key ID) for ECDSA authentication
470+
//
453471
// token: Secret K (D) for ECDSA authentication
454472
func LineSenderFromConf(ctx context.Context, conf string) (LineSender, error) {
455473
c, err := confFromStr(conf)

tcp_sender_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ func TestTcpPathologicalCasesFromEnv(t *testing.T) {
124124
expectedErr: "requestTimeout setting is not available",
125125
},
126126
{
127-
name: "min_throughput",
128-
config: "tcp::min_throughput=5;",
127+
name: "request_min_throughput",
128+
config: "tcp::request_min_throughput=5;",
129129
expectedErr: "minThroughput setting is not available",
130130
},
131131
{
@@ -158,8 +158,8 @@ func TestTcpPathologicalCasesFromConf(t *testing.T) {
158158
expectedErr: "retryTimeout setting is not available",
159159
},
160160
{
161-
name: "min_throughput",
162-
config: "tcp::min_throughput=5;",
161+
name: "request_min_throughput",
162+
config: "tcp::request_min_throughput=5;",
163163
expectedErr: "minThroughput setting is not available",
164164
},
165165
{

0 commit comments

Comments
 (0)