Skip to content

Commit a3b52b9

Browse files
authored
🔧 Make grpc dns probe interval configurable per client (#306)
* 🔧 Make grpc dns probe interval configurable per client Signed-off-by: gkumbhat <kumbhat.gaurav@gmail.com> * 🔧 Remove sec from variable name Signed-off-by: gkumbhat <kumbhat.gaurav@gmail.com> --------- Signed-off-by: gkumbhat <kumbhat.gaurav@gmail.com>
1 parent 738b4de commit a3b52b9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/clients.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ pub mod openai;
6969

7070
const DEFAULT_CONNECT_TIMEOUT_SEC: u64 = 60;
7171
const DEFAULT_REQUEST_TIMEOUT_SEC: u64 = 600;
72+
const DEFAULT_GRPC_PROBE_INTERVAL_SEC: u64 = 10;
7273

7374
pub type BoxStream<T> = Pin<Box<dyn Stream<Item = T> + Send>>;
7475

@@ -270,13 +271,19 @@ pub async fn create_grpc_client<C: Debug + Clone>(
270271
let mut base_url = Url::parse(&format!("{}://{}", protocol, &service_config.hostname)).unwrap();
271272
base_url.set_port(Some(port)).unwrap();
272273
debug!(%base_url, "creating gRPC client");
273-
let connect_timeout = Duration::from_secs(DEFAULT_REQUEST_TIMEOUT_SEC);
274+
let connect_timeout = Duration::from_secs(DEFAULT_CONNECT_TIMEOUT_SEC);
274275
let request_timeout = Duration::from_secs(
275276
service_config
276277
.request_timeout
277278
.unwrap_or(DEFAULT_REQUEST_TIMEOUT_SEC),
278279
);
280+
let grpc_dns_probe_interval = Duration::from_secs(
281+
service_config
282+
.grpc_dns_probe_interval
283+
.unwrap_or(DEFAULT_GRPC_PROBE_INTERVAL_SEC),
284+
);
279285
let mut builder = LoadBalancedChannel::builder((service_config.hostname.clone(), port))
286+
.dns_probe_interval(grpc_dns_probe_interval)
280287
.connect_timeout(connect_timeout)
281288
.timeout(request_timeout);
282289

src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ pub struct ServiceConfig {
6565
pub request_timeout: Option<u64>,
6666
/// TLS provider info
6767
pub tls: Option<Tls>,
68+
/// gRPC probe interval in seconds
69+
pub grpc_dns_probe_interval: Option<u64>,
6870
}
6971

7072
impl ServiceConfig {
@@ -74,6 +76,7 @@ impl ServiceConfig {
7476
port: Some(port),
7577
request_timeout: None,
7678
tls: None,
79+
grpc_dns_probe_interval: None,
7780
}
7881
}
7982
}

0 commit comments

Comments
 (0)