Skip to content

Commit cc74f21

Browse files
author
Devdutt Shenoi
committed
refactor: DRY to_object_store_path
1 parent 82574c0 commit cc74f21

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/storage/azure_blob.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
*/
1818
use super::object_storage::parseable_json_path;
1919
use super::{
20-
LogStream, ObjectStorage, ObjectStorageError, ObjectStorageProvider, PARSEABLE_ROOT_DIRECTORY,
21-
SCHEMA_FILE_NAME, STREAM_METADATA_FILE_NAME, STREAM_ROOT_DIRECTORY,
20+
to_object_store_path, LogStream, ObjectStorage, ObjectStorageError, ObjectStorageProvider, PARSEABLE_ROOT_DIRECTORY, SCHEMA_FILE_NAME, STREAM_METADATA_FILE_NAME, STREAM_ROOT_DIRECTORY
2221
};
2322
use async_trait::async_trait;
2423
use bytes::Bytes;
@@ -185,10 +184,6 @@ impl ObjectStorageProvider for AzureBlobConfig {
185184
}
186185
}
187186

188-
pub fn to_object_store_path(path: &RelativePath) -> StorePath {
189-
StorePath::from(path.as_str())
190-
}
191-
192187
// ObjStoreClient is generic client to enable interactions with different cloudprovider's
193188
// object store such as S3 and Azure Blob
194189
#[derive(Debug)]

src/storage/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use crate::{
2525
};
2626

2727
use chrono::Local;
28+
use object_store::path::Path;
29+
use relative_path::RelativePath;
2830
use serde::{Deserialize, Serialize};
2931

3032
use std::fmt::Debug;
@@ -260,3 +262,7 @@ pub enum ObjectStorageError {
260262
#[error("Error: {0}")]
261263
MetadataError(#[from] MetadataError),
262264
}
265+
266+
pub fn to_object_store_path(path: &RelativePath) -> Path {
267+
Path::from(path.as_str())
268+
}

src/storage/s3.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ use std::time::{Duration, Instant};
4343
use super::metrics_layer::MetricLayer;
4444
use super::object_storage::parseable_json_path;
4545
use super::{
46-
LogStream, ObjectStorageProvider, SCHEMA_FILE_NAME, STREAM_METADATA_FILE_NAME,
47-
STREAM_ROOT_DIRECTORY,
46+
to_object_store_path, LogStream, ObjectStorageProvider, SCHEMA_FILE_NAME, STREAM_METADATA_FILE_NAME, STREAM_ROOT_DIRECTORY
4847
};
4948
use crate::handlers::http::users::USERS_ROOT_DIR;
5049
use crate::metrics::storage::{s3::REQUEST_RESPONSE_TIME, StorageMetrics};
@@ -321,10 +320,6 @@ impl ObjectStorageProvider for S3Config {
321320
}
322321
}
323322

324-
fn to_object_store_path(path: &RelativePath) -> StorePath {
325-
StorePath::from(path.as_str())
326-
}
327-
328323
#[derive(Debug)]
329324
pub struct S3 {
330325
client: LimitStore<AmazonS3>,

0 commit comments

Comments
 (0)