Skip to content

Commit a97e195

Browse files
authored
docs: document connection pooling behavior (#2851)
Add connection pooling section to Client struct docs and update pool_idle_timeout and pool_max_idle_per_host methods.
1 parent e3093ed commit a97e195

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/async_impl/client.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ use tower_http::follow_redirect::FollowRedirect;
6969
/// are set to what is usually the most commonly desired value. To configure a
7070
/// `Client`, use `Client::builder()`.
7171
///
72-
/// The `Client` holds a connection pool internally, so it is advised that
72+
/// The `Client` holds a connection pool internally to improve performance
73+
/// by reusing connections and avoiding setup overhead, so it is advised that
7374
/// you create one and **reuse** it.
7475
///
7576
/// You do **not** have to wrap the `Client` in an [`Rc`] or [`Arc`] to **reuse** it,
7677
/// because it already uses an [`Arc`] internally.
7778
///
79+
/// # Connection Pooling
80+
///
81+
/// The connection pool can be configured using [`ClientBuilder`] methods
82+
/// with the `pool_` prefix, such as [`ClientBuilder::pool_idle_timeout`]
83+
/// and [`ClientBuilder::pool_max_idle_per_host`].
84+
///
7885
/// [`Rc`]: std::rc::Rc
7986
#[derive(Clone)]
8087
pub struct Client {
@@ -1406,6 +1413,8 @@ impl ClientBuilder {
14061413
}
14071414

14081415
/// Sets the maximum idle connection per host allowed in the pool.
1416+
///
1417+
/// Default is `usize::MAX` (no limit).
14091418
pub fn pool_max_idle_per_host(mut self, max: usize) -> ClientBuilder {
14101419
self.config.pool_max_idle_per_host = max;
14111420
self

0 commit comments

Comments
 (0)