Skip to content

Commit 212a0d7

Browse files
committed
renamed grace_timeout -> request_timeout; renamed min_throughput -> request_min_throughput
1 parent a8f327a commit 212a0d7

File tree

9 files changed

+56
-52
lines changed

9 files changed

+56
-52
lines changed

cpp_test/test_line_sender.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,22 +812,22 @@ TEST_CASE("HTTP basics") {
812812
"localhost",
813813
1};
814814
questdb::ingress::opts opts1conf = questdb::ingress::opts::from_conf(
815-
"http::addr=localhost:1;user=user;pass=pass;grace_timeout=5000;retry_timeout=5;");
815+
"http::addr=localhost:1;user=user;pass=pass;request_timeout=5000;retry_timeout=5;");
816816
questdb::ingress::opts opts2{
817817
questdb::ingress::line_sender_protocol::http,
818818
"localhost",
819819
"1"};
820820
questdb::ingress::opts opts2conf = questdb::ingress::opts::from_conf(
821-
"http::addr=localhost:1;token=token;min_throughput=1000;retry_timeout=0;");
821+
"http::addr=localhost:1;token=token;request_min_throughput=1000;retry_timeout=0;");
822822
opts1
823823
.user("user")
824824
.pass("pass")
825825
.max_buf_size(1000000)
826-
.grace_timeout(5000)
826+
.request_timeout(5000)
827827
.retry_timeout(5);
828828
opts2
829829
.token("token")
830-
.min_throughput(1000)
830+
.request_min_throughput(1000)
831831
.retry_timeout(0);
832832
questdb::ingress::line_sender sender1{opts1};
833833
questdb::ingress::line_sender sender1conf{opts1conf};

include/questdb/ingress/line_sender.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ bool line_sender_opts_retry_timeout(
751751
* The value is expressed as a number of bytes per second.
752752
*/
753753
LINESENDER_API
754-
bool line_sender_opts_min_throughput(
754+
bool line_sender_opts_request_min_throughput(
755755
line_sender_opts* opts,
756756
uint64_t bytes_per_sec,
757757
line_sender_error** err_out);
@@ -761,7 +761,7 @@ bool line_sender_opts_min_throughput(
761761
* The default is 5 seconds.
762762
*/
763763
LINESENDER_API
764-
bool line_sender_opts_grace_timeout(
764+
bool line_sender_opts_request_timeout(
765765
line_sender_opts* opts,
766766
uint64_t millis,
767767
line_sender_error** err_out);

include/questdb/ingress/line_sender.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,10 @@ namespace questdb::ingress
10191019
* The default is 100 KiB/s.
10201020
* The value is expressed as a number of bytes per second.
10211021
*/
1022-
opts& min_throughput(uint64_t bytes_per_sec)
1022+
opts& request_min_throughput(uint64_t bytes_per_sec)
10231023
{
10241024
line_sender_error::wrapped_call(
1025-
::line_sender_opts_min_throughput,
1025+
::line_sender_opts_request_min_throughput,
10261026
_impl,
10271027
bytes_per_sec);
10281028
return *this;
@@ -1032,10 +1032,10 @@ namespace questdb::ingress
10321032
* Grace request timeout before relying on the minimum throughput logic.
10331033
* The default is 5 seconds.
10341034
*/
1035-
opts& grace_timeout(uint64_t millis)
1035+
opts& request_timeout(uint64_t millis)
10361036
{
10371037
line_sender_error::wrapped_call(
1038-
::line_sender_opts_grace_timeout,
1038+
::line_sender_opts_request_timeout,
10391039
_impl,
10401040
millis);
10411041
return *this;

questdb-rs-ffi/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,24 +1122,24 @@ pub unsafe extern "C" fn line_sender_opts_retry_timeout(
11221122
/// The default is 100 KiB/s.
11231123
/// The value is expressed as a number of bytes per second.
11241124
#[no_mangle]
1125-
pub unsafe extern "C" fn line_sender_opts_min_throughput(
1125+
pub unsafe extern "C" fn line_sender_opts_request_min_throughput(
11261126
opts: *mut line_sender_opts,
11271127
bytes_per_sec: u64,
11281128
err_out: *mut *mut line_sender_error,
11291129
) -> bool {
1130-
upd_opts!(opts, err_out, min_throughput, bytes_per_sec)
1130+
upd_opts!(opts, err_out, request_min_throughput, bytes_per_sec)
11311131
}
11321132

11331133
/// Grace request timeout before relying on the minimum throughput logic.
11341134
/// The default is 5 seconds.
11351135
#[no_mangle]
1136-
pub unsafe extern "C" fn line_sender_opts_grace_timeout(
1136+
pub unsafe extern "C" fn line_sender_opts_request_timeout(
11371137
opts: *mut line_sender_opts,
11381138
millis: u64,
11391139
err_out: *mut *mut line_sender_error,
11401140
) -> bool {
1141-
let grace_timeout = std::time::Duration::from_millis(millis);
1142-
upd_opts!(opts, err_out, grace_timeout, grace_timeout)
1141+
let request_timeout = std::time::Duration::from_millis(millis);
1142+
upd_opts!(opts, err_out, request_timeout, request_timeout)
11431143
}
11441144

11451145
/// Set the HTTP user agent. Internal API. Do not use.

questdb-rs/src/ingress/http.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ impl TokenAuthParams {
4141

4242
#[derive(Debug, Clone)]
4343
pub(super) struct HttpConfig {
44-
pub(super) min_throughput: ConfigSetting<u64>,
44+
pub(super) request_min_throughput: ConfigSetting<u64>,
4545
pub(super) user_agent: ConfigSetting<Option<String>>,
4646
pub(super) retry_timeout: ConfigSetting<Duration>,
47-
pub(super) grace_timeout: ConfigSetting<Duration>,
47+
pub(super) request_timeout: ConfigSetting<Duration>,
4848
}
4949

5050
impl Default for HttpConfig {
5151
fn default() -> Self {
5252
Self {
53-
min_throughput: ConfigSetting::new_default(102400), // 100 KiB/s
53+
request_min_throughput: ConfigSetting::new_default(102400), // 100 KiB/s
5454
user_agent: ConfigSetting::new_default(None),
5555
retry_timeout: ConfigSetting::new_default(Duration::from_secs(10)),
56-
grace_timeout: ConfigSetting::new_default(Duration::from_secs(5)),
56+
request_timeout: ConfigSetting::new_default(Duration::from_secs(5)),
5757
}
5858
}
5959
}

questdb-rs/src/ingress/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,8 +1761,6 @@ impl SenderBuilder {
17611761
};
17621762
let mut builder = SenderBuilder::new(host, port, protocol);
17631763

1764-
// tls= tls_verify= tls_roots= tls_roots_password=
1765-
// TODO: no support in config string for WebPkiAndOsRoots
17661764
builder.tls_enabled.set_specified("tls", with_tls)?;
17671765

17681766
validate_auto_flush_params(&params)?;
@@ -1861,11 +1859,13 @@ impl SenderBuilder {
18611859
}
18621860

18631861
#[cfg(feature = "ilp-over-http")]
1864-
"min_throughput" => builder.min_throughput(parse_conf_value(key, val)?)?,
1862+
"request_min_throughput" => {
1863+
builder.request_min_throughput(parse_conf_value(key, val)?)?
1864+
}
18651865

18661866
#[cfg(feature = "ilp-over-http")]
1867-
"grace_timeout" => {
1868-
builder.grace_timeout(Duration::from_millis(parse_conf_value(key, val)?))?
1867+
"request_timeout" => {
1868+
builder.request_timeout(Duration::from_millis(parse_conf_value(key, val)?))?
18691869
}
18701870

18711871
#[cfg(feature = "ilp-over-http")]
@@ -2082,8 +2082,6 @@ impl SenderBuilder {
20822082

20832083
/// Set the path to a custom root certificate `.pem` file.
20842084
/// This is used to validate the server's certificate during the TLS handshake.
2085-
/// The file may be password-protected, if so, also specify the password.
2086-
/// via the [`tls_roots_password`](SenderBuilder::tls_roots_password) method.
20872085
///
20882086
/// See notes on how to test with [self-signed certificates](https://github.com/questdb/c-questdb-client/tree/main/tls_certs).
20892087
pub fn tls_roots<P: Into<PathBuf>>(self, path: P) -> Result<Self> {
@@ -2137,14 +2135,15 @@ impl SenderBuilder {
21372135
/// The default is 100 KiB/s.
21382136
/// The value is expressed as a number of bytes per second.
21392137
/// This is used to calculate additional request timeout, on top of
2140-
/// the [`grace_timeout`](SenderBuilder::grace_timeout).
2141-
pub fn min_throughput(mut self, value: u64) -> Result<Self> {
2138+
/// the [`request_timeout`](SenderBuilder::request_timeout).
2139+
pub fn request_min_throughput(mut self, value: u64) -> Result<Self> {
21422140
if let Some(http) = &mut self.http {
2143-
http.min_throughput.set_specified("min_throughput", value)?;
2141+
http.request_min_throughput
2142+
.set_specified("request_min_throughput", value)?;
21442143
} else {
21452144
return Err(error::fmt!(
21462145
ConfigError,
2147-
"\"min_throughput\" is supported only in ILP over HTTP."
2146+
"\"request_min_throughput\" is supported only in ILP over HTTP."
21482147
));
21492148
}
21502149
Ok(self)
@@ -2153,14 +2152,15 @@ impl SenderBuilder {
21532152
#[cfg(feature = "ilp-over-http")]
21542153
/// Grace request timeout before relying on the minimum throughput logic.
21552154
/// The default is 5 seconds.
2156-
/// See [`min_throughput`](SenderBuilder::min_throughput) for more details.
2157-
pub fn grace_timeout(mut self, value: Duration) -> Result<Self> {
2155+
/// See [`request_min_throughput`](SenderBuilder::request_min_throughput) for more details.
2156+
pub fn request_timeout(mut self, value: Duration) -> Result<Self> {
21582157
if let Some(http) = &mut self.http {
2159-
http.grace_timeout.set_specified("grace_timeout", value)?;
2158+
http.request_timeout
2159+
.set_specified("request_timeout", value)?;
21602160
} else {
21612161
return Err(error::fmt!(
21622162
ConfigError,
2163-
"\"grace_timeout\" is supported only in ILP over HTTP."
2163+
"\"request_timeout\" is supported only in ILP over HTTP."
21642164
));
21652165
}
21662166
Ok(self)
@@ -2663,8 +2663,8 @@ impl Sender {
26632663
));
26642664
}
26652665
let timeout = Duration::from_secs_f64(
2666-
(bytes.len() as f64) / (*state.config.min_throughput as f64),
2667-
) + *state.config.grace_timeout;
2666+
(bytes.len() as f64) / (*state.config.request_min_throughput as f64),
2667+
) + *state.config.request_timeout;
26682668
let request = state
26692669
.agent
26702670
.post(&state.url)

questdb-rs/src/ingress/tests.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,25 +360,26 @@ fn tcps_tls_roots_file_with_password() {
360360

361361
#[cfg(feature = "ilp-over-http")]
362362
#[test]
363-
fn http_min_throughput() {
364-
let builder = SenderBuilder::from_conf("http::addr=localhost;min_throughput=100;").unwrap();
363+
fn http_request_min_throughput() {
364+
let builder =
365+
SenderBuilder::from_conf("http::addr=localhost;request_min_throughput=100;").unwrap();
365366
let Some(http_config) = builder.http else {
366367
panic!("Expected Some(HttpConfig)");
367368
};
368-
assert_specified_eq(&http_config.min_throughput, 100u64);
369-
assert_defaulted_eq(&http_config.grace_timeout, Duration::from_millis(5000));
369+
assert_specified_eq(&http_config.request_min_throughput, 100u64);
370+
assert_defaulted_eq(&http_config.request_timeout, Duration::from_millis(5000));
370371
assert_defaulted_eq(&http_config.retry_timeout, Duration::from_millis(10000));
371372
}
372373

373374
#[cfg(feature = "ilp-over-http")]
374375
#[test]
375-
fn http_grace_timeout() {
376-
let builder = SenderBuilder::from_conf("http::addr=localhost;grace_timeout=100;").unwrap();
376+
fn http_request_timeout() {
377+
let builder = SenderBuilder::from_conf("http::addr=localhost;request_timeout=100;").unwrap();
377378
let Some(http_config) = builder.http else {
378379
panic!("Expected Some(HttpConfig)");
379380
};
380-
assert_defaulted_eq(&http_config.min_throughput, 102400u64);
381-
assert_specified_eq(&http_config.grace_timeout, Duration::from_millis(100));
381+
assert_defaulted_eq(&http_config.request_min_throughput, 102400u64);
382+
assert_specified_eq(&http_config.request_timeout, Duration::from_millis(100));
382383
assert_defaulted_eq(&http_config.retry_timeout, Duration::from_millis(10000));
383384
}
384385

@@ -389,8 +390,8 @@ fn http_retry_timeout() {
389390
let Some(http_config) = builder.http else {
390391
panic!("Expected Some(HttpConfig)");
391392
};
392-
assert_defaulted_eq(&http_config.min_throughput, 102400u64);
393-
assert_defaulted_eq(&http_config.grace_timeout, Duration::from_millis(5000));
393+
assert_defaulted_eq(&http_config.request_min_throughput, 102400u64);
394+
assert_defaulted_eq(&http_config.request_timeout, Duration::from_millis(5000));
394395
assert_specified_eq(&http_config.retry_timeout, Duration::from_millis(100));
395396
}
396397

questdb-rs/src/tests/http.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ fn test_token_auth() -> TestResult {
419419
}
420420

421421
#[test]
422-
fn test_grace_timeout() -> TestResult {
422+
fn test_request_timeout() -> TestResult {
423423
let mut buffer = Buffer::new();
424424
buffer
425425
.table("test")?
@@ -430,16 +430,19 @@ fn test_grace_timeout() -> TestResult {
430430
// Here we use a mock (tcp) server instead and don't send a response back.
431431
let server = MockServer::new()?;
432432

433-
let grace = Duration::from_millis(50);
433+
let request_timeout = Duration::from_millis(50);
434434
let time_start = std::time::Instant::now();
435-
let mut sender = server.lsb_http().grace_timeout(grace)?.build()?;
435+
let mut sender = server
436+
.lsb_http()
437+
.request_timeout(request_timeout)?
438+
.build()?;
436439
let res = sender.flush_and_keep(&buffer);
437440
let time_elapsed = time_start.elapsed();
438441
assert!(res.is_err());
439442
let err = res.unwrap_err();
440443
assert_eq!(err.code(), ErrorCode::SocketError);
441444
assert!(err.msg().contains("timed out reading response"));
442-
assert!(time_elapsed >= grace);
445+
assert!(time_elapsed >= request_timeout);
443446
Ok(())
444447
}
445448

system_test/questdb_line_sender.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ def set_sig(fn, restype, *argtypes):
355355
c_uint64,
356356
c_line_sender_error_p_p)
357357
set_sig(
358-
dll.line_sender_opts_min_throughput,
358+
dll.line_sender_opts_request_min_throughput,
359359
c_bool,
360360
c_line_sender_opts_p,
361361
c_uint64,
362362
c_line_sender_error_p_p)
363363
set_sig(
364-
dll.line_sender_opts_grace_timeout,
364+
dll.line_sender_opts_request_timeout,
365365
c_bool,
366366
c_line_sender_opts_p,
367367
c_uint64,

0 commit comments

Comments
 (0)