Skip to content

Commit f97c4cb

Browse files
authored
fix: enforce request timeout greater than zero (#74)
1 parent 0a42f25 commit f97c4cb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

questdb-rs/src/ingress/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2034,10 +2034,16 @@ impl SenderBuilder {
20342034
#[cfg(feature = "ilp-over-http")]
20352035
/// Additional time to wait on top of that calculated from the minimum throughput.
20362036
/// This accounts for the fixed latency of the HTTP request-response roundtrip.
2037-
/// The value is in milliseconds, and the default is 10 seconds.
2037+
/// The default is 10 seconds.
20382038
/// See also: [`request_min_throughput`](SenderBuilder::request_min_throughput).
20392039
pub fn request_timeout(mut self, value: Duration) -> Result<Self> {
20402040
if let Some(http) = &mut self.http {
2041+
if value.is_zero() {
2042+
return Err(error::fmt!(
2043+
ConfigError,
2044+
"\"request_timeout\" must be greater than 0."
2045+
));
2046+
}
20412047
http.request_timeout
20422048
.set_specified("request_timeout", value)?;
20432049
} else {

questdb-rs/src/ingress/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ fn incomplete_basic_auth() {
128128
);
129129
}
130130

131+
#[cfg(feature = "ilp-over-http")]
132+
#[test]
133+
fn zero_timeout_forbidden() {
134+
assert_conf_err(
135+
SenderBuilder::from_conf("http::addr=localhost;username=user123;request_timeout=0;"),
136+
"\"request_timeout\" must be greater than 0.",
137+
);
138+
139+
assert_conf_err(
140+
SenderBuilder::new(Protocol::Http, "localhost", 9000)
141+
.request_timeout(Duration::from_millis(0)),
142+
"\"request_timeout\" must be greater than 0.",
143+
);
144+
}
145+
131146
#[cfg(feature = "ilp-over-http")]
132147
#[test]
133148
fn misspelled_basic_auth() {

0 commit comments

Comments
 (0)