In #95, we refactored the Source API code to persist the reqwest::Client across requests, taking advantage of connection pooling.
The same logic should be applied when creating clients on our S3 interface code (I currently see 11 instances of client creation):
|
let client = reqwest::Client::new(); |
|
let client = self.create_client()?; |
(etc...)
Note that this will be a bit more involved than #95 as the S3Repository and AzureRepository isn't currently persisted across requests in the manner that the SourceApi is. The repositories are created on each call to api_client.get_backend_client():
|
Ok(Box::new(S3Repository { |
|
account_id: account_id.to_string(), |
|
repository_id: repository_id.to_string(), |
|
region, |
|
bucket, |
|
base_prefix: prefix, |
|
auth_method: auth.auth_type, |
|
access_key_id: auth.access_key_id, |
|
secret_access_key: auth.secret_access_key, |
|
})) |
|
} |
|
"az" => { |
|
let account_name: String = data_connection |
|
.details |
|
.account_name |
|
.clone() |
|
.unwrap_or_default(); |
|
|
|
let container_name: String = data_connection |
|
.details |
|
.container_name |
|
.clone() |
|
.unwrap_or_default(); |
|
|
|
let base_prefix: String = data_connection |
|
.details |
|
.base_prefix |
|
.clone() |
|
.unwrap_or_default(); |
|
|
|
Ok(Box::new(AzureRepository { |
|
account_id: account_id.to_string(), |
|
repository_id: repository_id.to_string(), |
|
account_name, |
|
container_name, |
|
base_prefix: format!("{}{}", base_prefix, repository_data.prefix), |
|
})) |
While the SourceApi is created just once at application startup:
|
let source_api = web::Data::new(SourceApi::new( |
|
source_api_url, |
|
source_api_key, |
|
source_api_proxy_url, |
|
)); |
In #95, we refactored the Source API code to persist the
reqwest::Clientacross requests, taking advantage of connection pooling.The same logic should be applied when creating clients on our S3 interface code (I currently see 11 instances of client creation):
data.source.coop/src/backends/s3.rs
Line 77 in 6305d65
data.source.coop/src/backends/s3.rs
Line 124 in 6305d65
(etc...)
Note that this will be a bit more involved than #95 as the
S3RepositoryandAzureRepositoryisn't currently persisted across requests in the manner that theSourceApiis. The repositories are created on each call toapi_client.get_backend_client():data.source.coop/src/apis/source/mod.rs
Lines 206 to 242 in 6305d65
While the
SourceApiis created just once at application startup:data.source.coop/src/main.rs
Lines 464 to 468 in 6305d65