Skip to content

Commit 78dfbf7

Browse files
committed
Add gRPC local subchannel support for tikv client.
Signed-off-by: yulai.li <[email protected]>
1 parent 74db41c commit 78dfbf7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tikv-client-common/src/security.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::Result;
44
use grpcio::{Channel, ChannelBuilder, ChannelCredentialsBuilder, Environment};
55
use regex::Regex;
66
use std::{
7+
ffi::CString,
78
fs::File,
89
io::Read,
910
path::{Path, PathBuf},
@@ -76,9 +77,12 @@ impl SecurityManager {
7677

7778
let addr = SCHEME_REG.replace(addr, "");
7879

80+
// Set grpc.use_local_subchannel_pool will ensure every TiKV client instance can has it's own
81+
// connection to TiKV server.
7982
let cb = ChannelBuilder::new(env)
8083
.keepalive_time(Duration::from_secs(10))
81-
.keepalive_timeout(Duration::from_secs(3));
84+
.keepalive_timeout(Duration::from_secs(3))
85+
.raw_cfg_int(CString::new("grpc.use_local_subchannel_pool").unwrap(), 1);
8286

8387
let channel = if self.ca.is_empty() {
8488
cb.connect(&addr)

0 commit comments

Comments
 (0)