Skip to content

Commit

Permalink
fix(client): no keep-alive always returning an error
Browse files Browse the repository at this point in the history
  • Loading branch information
dswij authored and seanmonstar committed Dec 22, 2023
1 parent 4d1ed57 commit 324408b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ where
&self,
pool_key: PoolKey,
) -> Result<pool::Pooled<PoolClient<B>, PoolKey>, ClientConnectError> {
// Return a single connection if pooling is not enabled
if !self.pool.is_enabled() {
return self
.connect_to(pool_key)
.await
.map_err(ClientConnectError::Normal);
}

// This actually races 2 different futures to try to get a ready
// connection the fastest, and to reduce connection churn.
//
Expand Down Expand Up @@ -1456,7 +1464,6 @@ impl fmt::Debug for Builder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Builder")
.field("client_config", &self.client_config)
//.field("conn_builder", &self.conn_builder)
.field("pool_config", &self.pool_config)
.finish()
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<T, K: Key> Pool<T, K> {
Pool { inner }
}

fn is_enabled(&self) -> bool {
pub(crate) fn is_enabled(&self) -> bool {
self.inner.is_some()
}

Expand Down

0 comments on commit 324408b

Please sign in to comment.