Skip to content

Commit 7878736

Browse files
authored
refactor(deps, api): improvements in hive-console-sdk lib (#7196)
1 parent 9e46359 commit 7878736

File tree

10 files changed

+38
-39
lines changed

10 files changed

+38
-39
lines changed

.changeset/eleven-birds-lie.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'hive-console-sdk-rs': minor
3+
'hive-apollo-router-plugin': patch
4+
---
5+
6+
Breaking;
7+
8+
- `UsageAgent` now accepts `Duration` for `connect_timeout` and `request_timeout` instead of `u64`.
9+
- `SupergraphFetcher` now accepts `Duration` for `connect_timeout` and `request_timeout` instead of `u64`.
10+
- `PersistedDocumentsManager` now accepts `Duration` for `connect_timeout` and `request_timeout` instead of `u64`.
11+
- Use original `graphql-parser` and `graphql-tools` crates instead of forked versions.

configs/cargo/Cargo.lock

Lines changed: 3 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/libraries/router/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ tokio = { version = "1.36.0", features = ["full"] }
4141
tower = { version = "0.5", features = ["full"] }
4242
http = "1"
4343
http-body-util = "0.1"
44-
graphql-parser = { version = "0.5.0", package = "graphql-parser-hive-fork" }
45-
graphql-tools = { version = "0.4.0", features = [
46-
"graphql_parser_fork",
47-
], default-features = false }
44+
graphql-tools = "0.4.0"
45+
graphql-parser = "0.4.1"
4846
lru = "0.16.0"
4947
md5 = "0.7.0"
5048
rand = "0.9.0"

packages/libraries/router/src/persisted_documents.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
2020
use std::env;
2121
use std::ops::ControlFlow;
2222
use std::sync::Arc;
23+
use std::time::Duration;
2324
use tower::{BoxError, ServiceBuilder, ServiceExt};
2425
use tracing::{debug, info, warn};
2526

@@ -102,8 +103,8 @@ impl PersistedDocumentsPlugin {
102103
key,
103104
endpoint,
104105
config.accept_invalid_certs.unwrap_or(false),
105-
config.connect_timeout.unwrap_or(5),
106-
config.request_timeout.unwrap_or(15),
106+
Duration::from_secs(config.connect_timeout.unwrap_or(5)),
107+
Duration::from_secs(config.request_timeout.unwrap_or(15)),
107108
config.retry_count.unwrap_or(3),
108109
config.cache_size.unwrap_or(1000),
109110
))),

packages/libraries/router/src/registry.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use sha2::Sha256;
77
use std::env;
88
use std::io::Write;
99
use std::thread;
10+
use std::time::Duration;
1011

1112
#[derive(Debug)]
1213
pub struct HiveRegistry {
@@ -126,8 +127,8 @@ impl HiveRegistry {
126127
endpoint,
127128
key,
128129
format!("hive-apollo-router/{}", PLUGIN_VERSION),
129-
5,
130-
60,
130+
Duration::from_secs(5),
131+
Duration::from_secs(60),
131132
accept_invalid_certs,
132133
)
133134
.map_err(|e| anyhow!("Failed to create SupergraphFetcher: {}", e))?,

packages/libraries/router/src/usage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ impl Plugin for UsagePlugin {
250250
endpoint,
251251
target_id,
252252
buffer_size,
253-
connect_timeout,
254-
request_timeout,
253+
Duration::from_secs(connect_timeout),
254+
Duration::from_secs(request_timeout),
255255
accept_invalid_certs,
256256
flush_interval,
257257
format!("hive-apollo-router/{}", PLUGIN_VERSION),

packages/libraries/sdk-rs/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ anyhow = "1"
2626
tracing = "0.1"
2727
serde = "1"
2828
tokio = { version = "1.36.0", features = ["full"] }
29-
graphql-parser = { version = "0.5.0", package = "graphql-parser-hive-fork" }
30-
graphql-tools = { version = "0.4.0", features = [
31-
"graphql_parser_fork",
32-
], default-features = false }
29+
graphql-tools = "0.4.0"
30+
graphql-parser = "0.4.1"
3331
md5 = "0.7.0"
3432
serde_json = "1"
3533
moka = { version = "0.12.10", features = ["future", "sync"] }

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ impl UsageAgent {
141141
endpoint: String,
142142
target_id: Option<String>,
143143
buffer_size: usize,
144-
connect_timeout: u64,
145-
request_timeout: u64,
144+
connect_timeout: Duration,
145+
request_timeout: Duration,
146146
accept_invalid_certs: bool,
147147
flush_interval: Duration,
148148
user_agent: String,
@@ -153,8 +153,8 @@ impl UsageAgent {
153153

154154
let reqwest_agent = reqwest::Client::builder()
155155
.danger_accept_invalid_certs(accept_invalid_certs)
156-
.connect_timeout(Duration::from_secs(connect_timeout))
157-
.timeout(Duration::from_secs(request_timeout))
156+
.connect_timeout(connect_timeout)
157+
.timeout(request_timeout)
158158
.build()
159159
.map_err(|err| err.to_string())
160160
.expect("Couldn't instantiate the http client for reports sending!");

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ impl PersistedDocumentsManager {
6060
key: String,
6161
endpoint: String,
6262
accept_invalid_certs: bool,
63-
connect_timeout: u64,
64-
request_timeout: u64,
63+
connect_timeout: Duration,
64+
request_timeout: Duration,
6565
retry_count: u32,
6666
cache_size: u64,
6767
) -> Self {
6868
let retry_policy = ExponentialBackoff::builder().build_with_max_retries(retry_count);
6969

7070
let reqwest_agent = reqwest::Client::builder()
7171
.danger_accept_invalid_certs(accept_invalid_certs)
72-
.connect_timeout(Duration::from_secs(connect_timeout))
73-
.timeout(Duration::from_secs(request_timeout))
72+
.connect_timeout(connect_timeout)
73+
.timeout(request_timeout)
7474
.build()
7575
.expect("Failed to create reqwest client");
7676
let agent = ClientBuilder::new(reqwest_agent)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl SupergraphFetcher {
1414
endpoint: String,
1515
key: String,
1616
user_agent: String,
17-
connect_timeout: u64,
18-
request_timeout: u64,
17+
connect_timeout: Duration,
18+
request_timeout: Duration,
1919
accept_invalid_certs: bool,
2020
) -> Result<Self, String> {
2121
let mut endpoint = endpoint;
@@ -29,8 +29,8 @@ impl SupergraphFetcher {
2929

3030
let client = reqwest::blocking::Client::builder()
3131
.danger_accept_invalid_certs(accept_invalid_certs)
32-
.connect_timeout(Duration::from_secs(connect_timeout))
33-
.timeout(Duration::from_secs(request_timeout))
32+
.connect_timeout(connect_timeout)
33+
.timeout(request_timeout)
3434
.build()
3535
.map_err(|e| e.to_string())?;
3636

0 commit comments

Comments
 (0)