Skip to content

Commit bb338ff

Browse files
committed
separate pool and h2 timer
1 parent 2270ace commit bb338ff

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/client/legacy/client.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ impl Builder {
10051005
}
10061006
}
10071007
/// Set an optional timeout for idle sockets being kept-alive.
1008-
/// A `Timer` is required for this to take effect
1008+
/// A `Timer` is required for this to take effect. See `Builder::pool_timer`
10091009
///
10101010
/// Pass `None` to disable timeout.
10111011
///
@@ -1022,7 +1022,7 @@ impl Builder {
10221022
///
10231023
/// let client = Client::builder(TokioExecutor::new())
10241024
/// .pool_idle_timeout(Duration::from_secs(30))
1025-
/// .timer(TokioTimer::new())
1025+
/// .pool_timer(TokioTimer::new())
10261026
/// .build_http();
10271027
///
10281028
/// # let infer: Client<_, http_body_util::Full<bytes::Bytes>> = client;
@@ -1389,22 +1389,30 @@ impl Builder {
13891389
self
13901390
}
13911391

1392-
/// Provide a timer to be used for timeouts and intervals.
1392+
/// Provide a timer to be used for h2
13931393
///
13941394
/// See the documentation of [`h2::client::Builder::timer`] for more
13951395
/// details.
13961396
///
13971397
/// [`h2::client::Builder::timer`]: https://docs.rs/h2/client/struct.Builder.html#method.timer
13981398
pub fn timer<M>(&mut self, timer: M) -> &mut Self
13991399
where
1400-
M: Timer + Clone + Send + Sync + 'static,
1400+
M: Timer + Send + Sync + 'static,
14011401
{
1402-
self.pool_timer = Some(timer::Timer::new(timer.clone()));
14031402
#[cfg(feature = "http2")]
14041403
self.h2_builder.timer(timer);
14051404
self
14061405
}
14071406

1407+
/// Provide a timer to be used for timeouts and intervals in connection pools.
1408+
pub fn pool_timer<M>(&mut self, timer: M) -> &mut Self
1409+
where
1410+
M: Timer + Clone + Send + Sync + 'static,
1411+
{
1412+
self.pool_timer = Some(timer::Timer::new(timer.clone()));
1413+
self
1414+
}
1415+
14081416
/// Set the maximum write buffer size for each HTTP/2 stream.
14091417
///
14101418
/// Default is currently 1MB, but may change.

0 commit comments

Comments
 (0)