Skip to content
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

feat(batch): improve connection pool value #13669

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Changes from 2 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
7 changes: 4 additions & 3 deletions src/rpc_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use anyhow::anyhow;
use async_trait::async_trait;
use futures::future::try_join_all;
use futures::stream::{BoxStream, Peekable};
use futures::{Stream, StreamExt};
use futures::{Stream, StreamExt, TryFutureExt};
use moka::future::Cache;
use rand::prelude::SliceRandom;
use risingwave_common::util::addr::HostAddr;
Expand Down Expand Up @@ -78,7 +78,7 @@ pub trait RpcClient: Send + Sync + 'static + Clone {
pub struct RpcClientPool<S> {
connection_pool_size: u16,

clients: Cache<HostAddr, Vec<S>>,
clients: Cache<HostAddr, Arc<Vec<S>>>,
}

impl<S> Default for RpcClientPool<S>
Expand Down Expand Up @@ -115,7 +115,8 @@ where
.clients
.try_get_with(
addr.clone(),
S::new_clients(addr.clone(), self.connection_pool_size as usize),
S::new_clients(addr.clone(), self.connection_pool_size as usize)
chenzl25 marked this conversation as resolved.
Show resolved Hide resolved
.map_ok(Arc::new),
)
.await
.map_err(|e| -> RpcError {
Expand Down
Loading