Skip to content

Commit a8fe749

Browse files
committed
More
1 parent 237c659 commit a8fe749

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@
4242
},
4343
"[yaml]": {
4444
"editor.defaultFormatter": "esbenp.prettier-vscode"
45+
},
46+
"[rust]": {
47+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
4548
}
4649
}

packages/libraries/router/src/registry.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,15 @@ impl HiveRegistry {
121121
env::set_var("APOLLO_ROUTER_HOT_RELOAD", "true");
122122

123123
let mut registry = HiveRegistry {
124-
fetcher: SupergraphFetcher::try_new(endpoint, key, accept_invalid_certs)
125-
.map_err(|e| anyhow!(e))?,
124+
fetcher: SupergraphFetcher::try_new(
125+
endpoint,
126+
key,
127+
"hive-apollo-router".to_string(),
128+
5,
129+
60,
130+
accept_invalid_certs,
131+
)
132+
.map_err(|e| anyhow!("Failed to create SupergraphFetcher: {}", e))?,
126133
file_name,
127134
logger,
128135
};

packages/libraries/sdk-rs/src/supergraph_fetcher.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
use std::time::Duration;
2+
13
#[derive(Debug)]
24
pub struct SupergraphFetcher {
35
client: reqwest::blocking::Client,
46
endpoint: String,
57
key: String,
8+
user_agent_prefix: String,
69
etag: Option<String>,
710
}
811

@@ -12,6 +15,9 @@ impl SupergraphFetcher {
1215
pub fn try_new(
1316
endpoint: String,
1417
key: String,
18+
user_agent_prefix: String,
19+
connect_timeout: u64,
20+
request_timeout: u64,
1521
accept_invalid_certs: bool,
1622
) -> Result<Self, String> {
1723
let mut endpoint = endpoint;
@@ -22,14 +28,19 @@ impl SupergraphFetcher {
2228
endpoint.push_str("/supergraph")
2329
}
2430
}
31+
2532
let client = reqwest::blocking::Client::builder()
2633
.danger_accept_invalid_certs(accept_invalid_certs)
34+
.connect_timeout(Duration::from_secs(connect_timeout))
35+
.timeout(Duration::from_secs(request_timeout))
2736
.build()
28-
.map_err(|err| err.to_string())?;
37+
.map_err(|e| e.to_string())?;
38+
2939
Ok(Self {
3040
client,
3141
endpoint,
3242
key,
43+
user_agent_prefix,
3344
etag: None,
3445
})
3546
}
@@ -40,7 +51,7 @@ impl SupergraphFetcher {
4051
headers.insert(
4152
reqwest::header::USER_AGENT,
4253
reqwest::header::HeaderValue::from_str(
43-
format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")).as_str(),
54+
format!("{}/{}", self.user_agent_prefix, COMMIT.unwrap_or("local")).as_str(),
4455
)
4556
.unwrap(),
4657
);

0 commit comments

Comments
 (0)