Skip to content

Commit 94c25d2

Browse files
authored
Improve documentation for http client timeout (#390)
1 parent 8a7bc6e commit 94c25d2

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/client/mod.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,36 +498,59 @@ impl ClientOptions {
498498
self
499499
}
500500

501-
/// Set a request timeout
501+
/// Set timeout for the overall request
502502
///
503-
/// The timeout is applied from when the request starts connecting until the
504-
/// response body has finished
503+
/// The timeout starts from when the request starts connecting until the
504+
/// response body has finished. If the request does not complete within the
505+
/// timeout, the client returns a timeout error.
506+
///
507+
/// Timeout errors are retried, subject to the [`RetryConfig`]
505508
///
506509
/// Default is 30 seconds
510+
///
511+
/// # See Also
512+
/// * [`Self::with_timeout_disabled`] to disable the timeout
513+
/// * [`Self::with_connect_timeout`] to set a timeout for the connect phase
514+
///
515+
/// [`RetryConfig`]: crate::RetryConfig
507516
pub fn with_timeout(mut self, timeout: Duration) -> Self {
508517
self.timeout = Some(ConfigValue::Parsed(timeout));
509518
self
510519
}
511520

512521
/// Disables the request timeout
513522
///
514-
/// See [`Self::with_timeout`]
523+
/// # See Also
524+
/// * [`Self::with_timeout`]
515525
pub fn with_timeout_disabled(mut self) -> Self {
516526
self.timeout = None;
517527
self
518528
}
519529

520530
/// Set a timeout for only the connect phase of a Client
521531
///
532+
/// This is the time allowed for the client to establish a connection
533+
/// and if the connection is not established within this time,
534+
/// the client returns a timeout error.
535+
///
536+
/// Timeout errors are retried, subject to the [`RetryConfig`]
537+
///
522538
/// Default is 5 seconds
539+
///
540+
/// # See Also
541+
/// * [`Self::with_timeout`] to set a timeout for the overall request
542+
/// * [`Self::with_connect_timeout_disabled`] to disable the connect timeout
543+
///
544+
/// [`RetryConfig`]: crate::RetryConfig
523545
pub fn with_connect_timeout(mut self, timeout: Duration) -> Self {
524546
self.connect_timeout = Some(ConfigValue::Parsed(timeout));
525547
self
526548
}
527549

528550
/// Disables the connection timeout
529551
///
530-
/// See [`Self::with_connect_timeout`]
552+
/// # See Also
553+
/// * [`Self::with_connect_timeout`]
531554
pub fn with_connect_timeout_disabled(mut self) -> Self {
532555
self.connect_timeout = None;
533556
self

src/client/retry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
//! A shared HTTP client implementation incorporating retries
18+
//! [`RetryConfig`] connection retry policy
1919
2020
use crate::client::backoff::{Backoff, BackoffConfig};
2121
use crate::client::builder::HttpRequestBuilder;

0 commit comments

Comments
 (0)