Skip to content

Commit

Permalink
feat(batch): improve connection pool value (#13669)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 authored Nov 27, 2023
1 parent 5cac7a8 commit 98639ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/rpc_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ pub use stream_client::{StreamClient, StreamClientPool, StreamClientPoolRef};
pub trait RpcClient: Send + Sync + 'static + Clone {
async fn new_client(host_addr: HostAddr) -> Result<Self>;

async fn new_clients(host_addr: HostAddr, size: usize) -> Result<Vec<Self>> {
try_join_all(repeat(host_addr).take(size).map(Self::new_client)).await
async fn new_clients(host_addr: HostAddr, size: usize) -> Result<Arc<Vec<Self>>> {
try_join_all(repeat(host_addr).take(size).map(Self::new_client))
.await
.map(Arc::new)
}
}

#[derive(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

0 comments on commit 98639ae

Please sign in to comment.