Skip to content

Improve documentation for http client timeout #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,36 +498,59 @@ impl ClientOptions {
self
}

/// Set a request timeout
/// Set timeout for the overall request
///
/// The timeout is applied from when the request starts connecting until the
/// response body has finished
/// The timeout starts from when the request starts connecting until the
/// response body has finished. If the request does not complete within the
/// timeout, the client returns a timeout error.
///
/// Timeout errors are retried, subject to the [`RetryConfig`]
///
/// Default is 30 seconds
///
/// # See Also
/// * [`Self::with_timeout_disabled`] to disable the timeout
/// * [`Self::with_connect_timeout`] to set a timeout for the connect phase
///
/// [`RetryConfig`]: crate::RetryConfig
pub fn with_timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(ConfigValue::Parsed(timeout));
self
}

/// Disables the request timeout
///
/// See [`Self::with_timeout`]
/// # See Also
/// * [`Self::with_timeout`]
pub fn with_timeout_disabled(mut self) -> Self {
self.timeout = None;
self
}

/// Set a timeout for only the connect phase of a Client
///
/// This is the time allowed for the client to establish a connection
/// and if the connection is not established within this time,
/// the client returns a timeout error.
///
/// Timeout errors are retried, subject to the [`RetryConfig`]
///
/// Default is 5 seconds
///
/// # See Also
/// * [`Self::with_timeout`] to set a timeout for the overall request
/// * [`Self::with_connect_timeout_disabled`] to disable the connect timeout
///
/// [`RetryConfig`]: crate::RetryConfig
pub fn with_connect_timeout(mut self, timeout: Duration) -> Self {
self.connect_timeout = Some(ConfigValue::Parsed(timeout));
self
}

/// Disables the connection timeout
///
/// See [`Self::with_connect_timeout`]
/// # See Also
/// * [`Self::with_connect_timeout`]
pub fn with_connect_timeout_disabled(mut self) -> Self {
self.connect_timeout = None;
self
Expand Down
2 changes: 1 addition & 1 deletion src/client/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//! A shared HTTP client implementation incorporating retries
//! [`RetryConfig`] connection retry policy

use crate::client::backoff::{Backoff, BackoffConfig};
use crate::client::builder::HttpRequestBuilder;
Expand Down
Loading