Skip to content

Commit affa665

Browse files
authored
Merge pull request #2847 from input-output-hk/djo/2827/refactor-client-lib-to-use-shared-aggregator-client
refactor(mithril-client-library): switch http backend to new shared `mithril-aggregator-client`
2 parents 488e3c1 + 97259ed commit affa665

29 files changed

+899
-2207
lines changed

Cargo.lock

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

internal/mithril-aggregator-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator-client"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
description = "Client to request data from a Mithril Aggregator"
55
authors.workspace = true
66
documentation.workspace = true

internal/mithril-aggregator-client/src/builder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Context;
2-
use reqwest::{Client, IntoUrl, Proxy, Url};
2+
use reqwest::{Client, IntoUrl, Url};
33
use slog::{Logger, o};
44
use std::collections::HashMap;
55
use std::sync::Arc;
@@ -16,6 +16,7 @@ pub struct AggregatorClientBuilder {
1616
api_version_provider: Option<Arc<APIVersionProvider>>,
1717
additional_headers: Option<HashMap<String, String>>,
1818
timeout_duration: Option<Duration>,
19+
#[cfg(not(target_family = "wasm"))]
1920
relay_endpoint: Option<String>,
2021
logger: Option<Logger>,
2122
}
@@ -30,6 +31,7 @@ impl AggregatorClientBuilder {
3031
api_version_provider: None,
3132
additional_headers: None,
3233
timeout_duration: None,
34+
#[cfg(not(target_family = "wasm"))]
3335
relay_endpoint: None,
3436
logger: None,
3537
}
@@ -63,6 +65,9 @@ impl AggregatorClientBuilder {
6365
}
6466

6567
/// Set the address of the relay
68+
///
69+
/// _Not available on wasm platforms_
70+
#[cfg(not(target_family = "wasm"))]
6671
pub fn with_relay_endpoint(mut self, relay_endpoint: Option<String>) -> Self {
6772
self.relay_endpoint = relay_endpoint;
6873
self
@@ -77,9 +82,15 @@ impl AggregatorClientBuilder {
7782
let logger = self.logger.unwrap_or_else(|| Logger::root(slog::Discard, o!()));
7883
let api_version_provider = self.api_version_provider.unwrap_or_default();
7984
let additional_headers = self.additional_headers.unwrap_or_default();
85+
#[cfg(not(target_family = "wasm"))]
8086
let mut client_builder = Client::builder();
87+
#[cfg(target_family = "wasm")]
88+
let client_builder = Client::builder();
8189

90+
#[cfg(not(target_family = "wasm"))]
8291
if let Some(relay_endpoint) = self.relay_endpoint {
92+
use reqwest::Proxy;
93+
8394
client_builder = client_builder
8495
.proxy(Proxy::all(relay_endpoint).with_context(|| "Relay proxy creation failed")?)
8596
}

mithril-client/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client"
3-
version = "0.12.37"
3+
version = "0.13.0"
44
description = "Mithril client library"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -52,20 +52,19 @@ num-integer-backend = ["mithril-common/num-integer-backend"]
5252

5353
[dependencies]
5454
anyhow = { workspace = true }
55-
async-recursion = { workspace = true }
5655
async-trait = { workspace = true }
5756
chrono = { workspace = true }
5857
flate2 = { version = "1.1.4", optional = true }
5958
flume = { version = "0.11.1", optional = true }
6059
futures = "0.3.31"
60+
mithril-aggregator-client = { path = "../internal/mithril-aggregator-client", version = ">=0.1.4" }
6161
mithril-common = { path = "../mithril-common", version = ">=0.6", default-features = false }
6262
reqwest = { workspace = true, default-features = false, features = [
6363
"charset",
6464
"http2",
6565
"macos-system-configuration",
6666
"stream",
6767
] }
68-
semver = { workspace = true }
6968
serde = { workspace = true }
7069
serde_json = { workspace = true }
7170
slog = { workspace = true }

0 commit comments

Comments
 (0)