Compare commits

...

2 Commits

Author SHA1 Message Date
Arpad Müller
3c4221db2c fmt 2024-12-13 18:54:20 +01:00
Arpad Müller
00ff70c905 Pass down timeouts to the reqwest client 2024-12-13 18:32:46 +01:00
3 changed files with 17 additions and 3 deletions

1
Cargo.lock generated
View File

@@ -5062,6 +5062,7 @@ dependencies = [
"once_cell",
"pin-project-lite",
"rand 0.8.5",
"reqwest",
"scopeguard",
"serde",
"serde_json",

View File

@@ -18,6 +18,7 @@ camino = { workspace = true, features = ["serde1"] }
humantime-serde.workspace = true
hyper = { workspace = true, features = ["client"] }
futures.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio = { workspace = true, features = ["sync", "fs", "io-util"] }

View File

@@ -8,6 +8,7 @@ use std::io;
use std::num::NonZeroU32;
use std::pin::Pin;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use std::time::SystemTime;
@@ -15,7 +16,7 @@ use super::REMOTE_STORAGE_PREFIX_SEPARATOR;
use anyhow::Context;
use anyhow::Result;
use azure_core::request_options::{IfMatchCondition, MaxResults, Metadata, Range};
use azure_core::{Continuable, RetryOptions};
use azure_core::{Continuable, HttpClient, RetryOptions, TransportOptions};
use azure_storage::StorageCredentials;
use azure_storage_blobs::blob::CopyStatus;
use azure_storage_blobs::prelude::ClientBuilder;
@@ -81,8 +82,9 @@ impl AzureBlobStorage {
};
// we have an outer retry
let builder = ClientBuilder::new(account, credentials).retry(RetryOptions::none());
let builder = ClientBuilder::new(account, credentials)
.retry(RetryOptions::none())
.transport(TransportOptions::new(reqwest_client(small_timeout)));
let client = builder.container_client(azure_config.container_name.to_owned());
let max_keys_per_list_response =
@@ -261,6 +263,16 @@ impl AzureBlobStorage {
}
}
fn reqwest_client(timeout: Duration) -> Arc<dyn HttpClient> {
let client = reqwest::ClientBuilder::new()
.pool_max_idle_per_host(0)
.read_timeout(timeout)
.connect_timeout(timeout)
.build()
.expect("failed to build `reqwest` client");
Arc::new(client)
}
fn to_azure_metadata(metadata: StorageMetadata) -> Metadata {
let mut res = Metadata::new();
for (k, v) in metadata.0.into_iter() {