Skip to content

Commit 6b9ee81

Browse files
committed
Duration
1 parent 766bd0e commit 6b9ee81

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

lib/executor/src/executors/map.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{
22
collections::{BTreeMap, HashMap},
33
sync::Arc,
4-
time::Duration,
54
};
65

76
use bytes::{BufMut, Bytes, BytesMut};
@@ -57,9 +56,7 @@ impl SubgraphExecutorMap {
5756
let https = HttpsConnector::new();
5857
let client: HttpClient = Client::builder(TokioExecutor::new())
5958
.pool_timer(TokioTimer::new())
60-
.pool_idle_timeout(Duration::from_secs(
61-
config.traffic_shaping.pool_idle_timeout_seconds,
62-
))
59+
.pool_idle_timeout(config.traffic_shaping.pool_idle_timeout)
6360
.pool_max_idle_per_host(config.traffic_shaping.max_connections_per_host)
6461
.build(https);
6562

lib/router-config/src/traffic_shaping.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Duration;
2+
13
use schemars::JsonSchema;
24
use serde::{Deserialize, Serialize};
35

@@ -9,8 +11,13 @@ pub struct TrafficShapingConfig {
911
pub max_connections_per_host: usize,
1012

1113
/// Timeout for idle sockets being kept-alive.
12-
#[serde(default = "default_pool_idle_timeout_seconds")]
13-
pub pool_idle_timeout_seconds: u64,
14+
#[serde(
15+
default = "default_pool_idle_timeout",
16+
deserialize_with = "humantime_serde::deserialize",
17+
serialize_with = "humantime_serde::serialize"
18+
)]
19+
#[schemars(with = "String")]
20+
pub pool_idle_timeout: Duration,
1421

1522
/// Enables/disables request deduplication to subgraphs.
1623
///
@@ -24,7 +31,7 @@ impl Default for TrafficShapingConfig {
2431
fn default() -> Self {
2532
Self {
2633
max_connections_per_host: default_max_connections_per_host(),
27-
pool_idle_timeout_seconds: default_pool_idle_timeout_seconds(),
34+
pool_idle_timeout: default_pool_idle_timeout(),
2835
dedupe_enabled: default_dedupe_enabled(),
2936
}
3037
}
@@ -34,8 +41,8 @@ fn default_max_connections_per_host() -> usize {
3441
100
3542
}
3643

37-
fn default_pool_idle_timeout_seconds() -> u64 {
38-
50
44+
fn default_pool_idle_timeout() -> Duration {
45+
Duration::from_secs(50)
3946
}
4047

4148
fn default_dedupe_enabled() -> bool {

0 commit comments

Comments
 (0)