Skip to content

Commit bf179ce

Browse files
committed
fix: cargo fmt and clippy
1 parent 3a597c1 commit bf179ce

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

crates/batcher/src/lib.rs

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,10 @@ impl Batcher {
15681568
let batch_merkle_root_hex = hex::encode(batch_merkle_root);
15691569
info!("Batch merkle root: 0x{}", batch_merkle_root_hex);
15701570
let file_name = batch_merkle_root_hex.clone() + ".json";
1571-
1572-
let batch_data_pointer = self.upload_batch_to_multiple_s3(batch_bytes, &file_name).await?;
1571+
1572+
let batch_data_pointer = self
1573+
.upload_batch_to_multiple_s3(batch_bytes, &file_name)
1574+
.await?;
15731575
if let Err(e) = self
15741576
.telemetry
15751577
.task_uploaded_to_s3(&batch_merkle_root_hex)
@@ -1892,34 +1894,59 @@ impl Batcher {
18921894
) -> Result<String, BatcherError> {
18931895
// Upload to both S3 buckets and collect successful URLs
18941896
let mut successful_urls = Vec::new();
1895-
1897+
18961898
// Try primary S3 upload
1897-
if let Ok(_) = self.upload_batch_to_s3(&self.s3_client, batch_bytes, file_name, &self.s3_bucket_name).await {
1899+
if self
1900+
.upload_batch_to_s3(
1901+
&self.s3_client,
1902+
batch_bytes,
1903+
file_name,
1904+
&self.s3_bucket_name,
1905+
)
1906+
.await
1907+
.is_ok()
1908+
{
18981909
let primary_url = format!("{}/{}", self.download_endpoint, file_name);
18991910
successful_urls.push(primary_url.clone());
19001911
info!("Successfully uploaded batch to primary S3: {}", primary_url);
19011912
} else {
19021913
warn!("Failed to upload batch to primary S3");
19031914
}
1904-
1915+
19051916
// Try secondary S3 upload
1906-
if let Ok(_) = self.upload_batch_to_s3(&self.s3_client_secondary, batch_bytes, file_name, &self.s3_bucket_name_secondary).await {
1917+
if self
1918+
.upload_batch_to_s3(
1919+
&self.s3_client_secondary,
1920+
batch_bytes,
1921+
file_name,
1922+
&self.s3_bucket_name_secondary,
1923+
)
1924+
.await
1925+
.is_ok()
1926+
{
19071927
let secondary_url = format!("{}/{}", self.download_endpoint_secondary, file_name);
19081928
successful_urls.push(secondary_url.clone());
1909-
info!("Successfully uploaded batch to secondary S3: {}", secondary_url);
1929+
info!(
1930+
"Successfully uploaded batch to secondary S3: {}",
1931+
secondary_url
1932+
);
19101933
} else {
19111934
warn!("Failed to upload batch to secondary S3");
19121935
}
1913-
1936+
19141937
// Update metrics with number of available data services
1915-
self.metrics.available_data_services.set(successful_urls.len() as i64);
1916-
1938+
self.metrics
1939+
.available_data_services
1940+
.set(successful_urls.len() as i64);
1941+
19171942
// If no uploads succeeded, return error
19181943
if successful_urls.is_empty() {
19191944
error!("Failed to upload batch to both S3 buckets");
1920-
return Err(BatcherError::BatchUploadError("Failed to upload to any S3 bucket".to_string()));
1945+
return Err(BatcherError::BatchUploadError(
1946+
"Failed to upload to any S3 bucket".to_string(),
1947+
));
19211948
}
1922-
1949+
19231950
Ok(successful_urls.join(","))
19241951
}
19251952

crates/batcher/src/s3/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use aws_config::meta::region::RegionProviderChain;
22
use aws_config::BehaviorVersion;
3+
use aws_sdk_s3::config::Region;
34
use aws_sdk_s3::error::SdkError;
45
use aws_sdk_s3::operation::put_object::{PutObjectError, PutObjectOutput};
56
use aws_sdk_s3::primitives::ByteStream;
67
use aws_sdk_s3::Client;
7-
use aws_sdk_s3::config::Region;
88
use log::info;
99

1010
pub struct S3Config {
@@ -16,16 +16,19 @@ pub struct S3Config {
1616

1717
pub async fn create_client(s3_config: S3Config) -> Client {
1818
let mut config = aws_config::defaults(BehaviorVersion::latest());
19-
19+
2020
if let Some(region) = s3_config.region {
21-
let region_provider = RegionProviderChain::first_try(Region::new(region)).or_else("us-east-2");
21+
let region_provider =
22+
RegionProviderChain::first_try(Region::new(region)).or_else("us-east-2");
2223
config = config.region(region_provider);
2324
} else {
2425
let region_provider = RegionProviderChain::default_provider().or_else("us-east-2");
2526
config = config.region(region_provider);
2627
}
2728

28-
if let (Some(access_key_id), Some(secret_access_key)) = (s3_config.access_key_id, s3_config.secret_access_key) {
29+
if let (Some(access_key_id), Some(secret_access_key)) =
30+
(s3_config.access_key_id, s3_config.secret_access_key)
31+
{
2932
let credentials = aws_sdk_s3::config::Credentials::new(
3033
access_key_id,
3134
secret_access_key,

0 commit comments

Comments
 (0)