Skip to content

Commit 402da7c

Browse files
committed
More
1 parent d2d3889 commit 402da7c

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

packages/libraries/router/src/registry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::consts::PLUGIN_VERSION;
22
use crate::registry_logger::Logger;
33
use anyhow::{anyhow, Result};
4-
use hive_console_sdk::supergraph_fetcher::builder::SupergraphFetcherBuilder;
54
use hive_console_sdk::supergraph_fetcher::sync::SupergraphFetcherSyncState;
65
use hive_console_sdk::supergraph_fetcher::SupergraphFetcher;
76
use sha2::Digest;
@@ -125,7 +124,7 @@ impl HiveRegistry {
125124
env::set_var("APOLLO_ROUTER_HOT_RELOAD", "true");
126125
}
127126

128-
let mut fetcher = SupergraphFetcherBuilder::new()
127+
let mut fetcher = SupergraphFetcher::builder()
129128
.key(key)
130129
.user_agent(format!("hive-apollo-router/{}", PLUGIN_VERSION))
131130
.accept_invalid_certs(accept_invalid_certs);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl SupergraphFetcherBuilder {
135135
let circuit_breaker = self
136136
.circuit_breaker
137137
.clone()
138+
.unwrap_or_default()
138139
.build_async()
139140
.map_err(SupergraphFetcherError::CircuitBreakerCreationError);
140141
circuit_breaker.map(|cb| (endpoint, cb))

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct SupergraphFetcherBuilder {
1616
pub(crate) request_timeout: Duration,
1717
pub(crate) accept_invalid_certs: bool,
1818
pub(crate) retry_policy: ExponentialBackoff,
19-
pub(crate) circuit_breaker: CircuitBreakerBuilder,
19+
pub(crate) circuit_breaker: Option<CircuitBreakerBuilder>,
2020
}
2121

2222
impl Default for SupergraphFetcherBuilder {
@@ -29,7 +29,7 @@ impl Default for SupergraphFetcherBuilder {
2929
request_timeout: Duration::from_secs(60),
3030
accept_invalid_certs: false,
3131
retry_policy: ExponentialBackoff::builder().build_with_max_retries(3),
32-
circuit_breaker: CircuitBreakerBuilder::default(),
32+
circuit_breaker: None,
3333
}
3434
}
3535
}
@@ -101,6 +101,11 @@ impl SupergraphFetcherBuilder {
101101
self
102102
}
103103

104+
pub fn circuit_breaker(&mut self, builder: CircuitBreakerBuilder) -> &mut Self {
105+
self.circuit_breaker = Some(builder);
106+
self
107+
}
108+
104109
pub(crate) fn validate_endpoints(&self) -> Result<(), SupergraphFetcherError> {
105110
if self.endpoints.is_empty() {
106111
return Err(SupergraphFetcherError::MissingConfigurationOption(

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fmt::Display;
22
use tokio::sync::RwLock;
33

44
use crate::circuit_breaker::CircuitBreakerError;
5+
use crate::supergraph_fetcher::async_::SupergraphFetcherAsyncState;
56
use recloser::AsyncRecloser;
67
use recloser::Recloser;
78
use reqwest::header::HeaderValue;
@@ -33,6 +34,13 @@ enum SupergraphFetcherAsyncOrSyncClient {
3334
},
3435
}
3536

37+
// Doesn't matter which one we implement this for, both have the same builder
38+
impl SupergraphFetcher<SupergraphFetcherAsyncState> {
39+
pub fn builder() -> builder::SupergraphFetcherBuilder {
40+
builder::SupergraphFetcherBuilder::default()
41+
}
42+
}
43+
3644
pub enum SupergraphFetcherError {
3745
FetcherCreationError(reqwest::Error),
3846
NetworkError(reqwest_middleware::Error),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ impl SupergraphFetcherBuilder {
170170
let circuit_breaker = self
171171
.circuit_breaker
172172
.clone()
173+
.unwrap_or_default()
173174
.build_sync()
174175
.map_err(SupergraphFetcherError::CircuitBreakerCreationError);
175176
circuit_breaker.map(|cb| (endpoint, cb))

0 commit comments

Comments
 (0)