Skip to content

Commit

Permalink
chore(volo-http): do not use Option<Duration> for timeout interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
  • Loading branch information
yukiiiteru committed Aug 9, 2024
1 parent fe68dcd commit 7791e95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion volo-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-http"
version = "0.2.12"
version = "0.2.13"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
24 changes: 12 additions & 12 deletions volo-http/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ pub struct ClientBuilder<IL, OL, C, LB> {
/// This is unstable now and may be changed in the future.
#[doc(hidden)]
pub struct BuilderConfig {
timeout: Option<Duration>,
stat_enable: bool,
fail_on_error_status: bool,
pub timeout: Option<Duration>,
pub stat_enable: bool,
pub fail_on_error_status: bool,
#[cfg(feature = "__tls")]
disable_tls: bool,
pub disable_tls: bool,
}

impl Default for BuilderConfig {
Expand Down Expand Up @@ -605,29 +605,29 @@ impl<IL, OL, C, LB> ClientBuilder<IL, OL, C, LB> {
}

/// Set the maximum idle time for a connection.
pub fn set_connect_timeout(&mut self, timeout: Option<Duration>) -> &mut Self {
self.connector.set_connect_timeout(timeout);
pub fn set_connect_timeout(&mut self, timeout: Duration) -> &mut Self {
self.connector.set_connect_timeout(Some(timeout));
self
}

/// Set the maximum idle time for reading data from the connection.
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) -> &mut Self {
self.connector.set_read_timeout(timeout);
pub fn set_read_timeout(&mut self, timeout: Duration) -> &mut Self {
self.connector.set_read_timeout(Some(timeout));
self
}

/// Set the maximum idle time for writing data to the connection.
pub fn set_write_timeout(&mut self, timeout: Option<Duration>) -> &mut Self {
self.connector.set_write_timeout(timeout);
pub fn set_write_timeout(&mut self, timeout: Duration) -> &mut Self {
self.connector.set_write_timeout(Some(timeout));
self
}

/// Set the maximin idle time for the request.
///
/// The whole request includes connecting, writting, and reading the whole HTTP protocol
/// headers (without reading response body).
pub fn set_request_timeout(&mut self, timeout: Option<Duration>) -> &mut Self {
self.builder_config.timeout = timeout;
pub fn set_request_timeout(&mut self, timeout: Duration) -> &mut Self {
self.builder_config.timeout = Some(timeout);
self
}

Expand Down

0 comments on commit 7791e95

Please sign in to comment.