fix conversion type && make the retry count configurable

This commit is contained in:
Tommy Verrall
2025-10-20 11:15:31 +02:00
parent db813b6e3e
commit 6f4dfd1dab
5 changed files with 19 additions and 7 deletions
@@ -119,6 +119,7 @@ where
user_agent,
core.debug.topology.minimum_gateway_performance,
core.debug.topology.ignore_ingress_epoch_role,
None,
)
.await?
};
@@ -178,6 +178,7 @@ where
user_agent,
core.debug.topology.minimum_gateway_performance,
core.debug.topology.ignore_ingress_epoch_role,
None,
)
.await?
};
+7 -5
View File
@@ -137,19 +137,21 @@ pub async fn gateways_for_init(
user_agent: Option<UserAgent>,
minimum_performance: u8,
ignore_epoch_roles: bool,
retry_count: Option<usize>,
) -> Result<Vec<RoutingNode>, ClientCoreError> {
// Build client with ALL URLs for fallback support
let nym_api_urls: Vec<nym_http_api_client::Url> = nym_apis
.iter()
.filter_map(|url| nym_http_api_client::Url::parse(url.as_str()).ok())
.map(|url| nym_http_api_client::Url::from(url.clone()))
.collect();
if nym_api_urls.is_empty() {
return Err(ClientCoreError::ListOfNymApisIsEmpty);
}
let retry_count = retry_count.unwrap_or(3);
let mut builder = nym_http_api_client::ClientBuilder::new_with_urls(nym_api_urls.clone())
.with_retries(3)
.with_retries(retry_count)
.with_bincode();
if let Some(user_agent) = user_agent {
@@ -430,7 +432,7 @@ mod tests {
let nym_api_urls: Vec<nym_http_api_client::Url> = urls
.iter()
.filter_map(|url| nym_http_api_client::Url::parse(url.as_str()).ok())
.map(|url| nym_http_api_client::Url::from(url.clone()))
.collect();
assert_eq!(nym_api_urls.len(), 1, "Should have exactly one URL");
@@ -446,7 +448,7 @@ mod tests {
let nym_api_urls: Vec<nym_http_api_client::Url> = urls
.iter()
.filter_map(|url| nym_http_api_client::Url::parse(url.as_str()).ok())
.map(|url| nym_http_api_client::Url::from(url.clone()))
.collect();
assert_eq!(nym_api_urls.len(), 3, "Should have all three URLs");
@@ -462,7 +464,7 @@ mod tests {
let nym_api_urls: Vec<nym_http_api_client::Url> = urls
.iter()
.filter_map(|url| nym_http_api_client::Url::parse(url.as_str()).ok())
.map(|url| nym_http_api_client::Url::from(url.clone()))
.collect();
assert!(nym_api_urls.is_empty(), "Empty list should remain empty");
+9 -2
View File
@@ -160,8 +160,14 @@ pub async fn setup_gateway_from_api(
minimum_performance: u8,
ignore_epoch_roles: bool,
) -> Result<InitialisationResult, WasmCoreError> {
let gateways =
gateways_for_init(nym_apis, None, minimum_performance, ignore_epoch_roles).await?;
let gateways = gateways_for_init(
nym_apis,
None,
minimum_performance,
ignore_epoch_roles,
None,
)
.await?;
setup_gateway_wasm(client_store, force_tls, chosen_gateway, gateways).await
}
@@ -176,6 +182,7 @@ pub async fn current_gateways_wasm(
user_agent,
minimum_performance,
ignore_epoch_roles,
None,
)
.await
}
+1
View File
@@ -570,6 +570,7 @@ where
user_agent,
topology_cfg.minimum_gateway_performance,
topology_cfg.ignore_ingress_epoch_role,
None,
)
.await
}