Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3368300
D8440.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8440.diff
View Options
diff --git a/services/blob/src/database/errors.rs b/services/blob/src/database/errors.rs
new file mode 100644
--- /dev/null
+++ b/services/blob/src/database/errors.rs
@@ -0,0 +1,39 @@
+use std::fmt::{Display, Formatter};
+
+use aws_sdk_dynamodb::Error as DynamoDBError;
+use comm_services_lib::database::DBItemError;
+
+use crate::s3::S3PathError;
+
+#[derive(
+ Debug, derive_more::Display, derive_more::From, derive_more::Error,
+)]
+pub enum Error {
+ #[display(...)]
+ AwsSdk(DynamoDBError),
+ #[display(...)]
+ Attribute(DBItemError),
+ #[display(...)]
+ Blob(BlobDBError),
+ #[display(...)]
+ ItemAlreadyExists,
+}
+
+#[derive(Debug)]
+pub enum BlobDBError {
+ HolderAlreadyExists(String),
+ InvalidS3Path(S3PathError),
+}
+
+impl Display for BlobDBError {
+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
+ match self {
+ BlobDBError::HolderAlreadyExists(holder) => {
+ write!(f, "Item for given holder [{}] already exists", holder)
+ }
+ BlobDBError::InvalidS3Path(err) => err.fmt(f),
+ }
+ }
+}
+
+impl std::error::Error for BlobDBError {}
diff --git a/services/blob/src/database/mod.rs b/services/blob/src/database/mod.rs
new file mode 100644
--- /dev/null
+++ b/services/blob/src/database/mod.rs
@@ -0,0 +1,2 @@
+pub mod errors;
+pub mod old;
diff --git a/services/blob/src/database.rs b/services/blob/src/database/old.rs
rename from services/blob/src/database.rs
rename to services/blob/src/database/old.rs
--- a/services/blob/src/database.rs
+++ b/services/blob/src/database/old.rs
@@ -1,14 +1,9 @@
use aws_sdk_dynamodb::{
operation::get_item::GetItemOutput, types::AttributeValue,
- Error as DynamoDBError,
};
use chrono::{DateTime, Utc};
-use comm_services_lib::database::{self, DBItemError};
-use std::{
- collections::HashMap,
- fmt::{Display, Formatter},
- sync::Arc,
-};
+use comm_services_lib::database;
+use std::{collections::HashMap, sync::Arc};
use tracing::error;
use crate::{
@@ -19,9 +14,11 @@
BLOB_S3_BUCKET_NAME, BLOB_TABLE_BLOB_HASH_FIELD, BLOB_TABLE_CREATED_FIELD,
BLOB_TABLE_NAME, BLOB_TABLE_S3_PATH_FIELD,
},
- s3::{S3Path, S3PathError},
+ s3::S3Path,
};
+use super::errors::{BlobDBError, Error};
+
#[derive(Clone, Debug)]
pub struct BlobItem {
pub blob_hash: String,
@@ -306,34 +303,3 @@
Ok(())
}
}
-
-#[derive(
- Debug, derive_more::Display, derive_more::From, derive_more::Error,
-)]
-pub enum Error {
- #[display(...)]
- AwsSdk(DynamoDBError),
- #[display(...)]
- Attribute(DBItemError),
- #[display(...)]
- Blob(BlobDBError),
-}
-
-#[derive(Debug)]
-pub enum BlobDBError {
- HolderAlreadyExists(String),
- InvalidS3Path(S3PathError),
-}
-
-impl Display for BlobDBError {
- fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
- match self {
- BlobDBError::HolderAlreadyExists(holder) => {
- write!(f, "Item for given holder [{}] already exists", holder)
- }
- BlobDBError::InvalidS3Path(err) => err.fmt(f),
- }
- }
-}
-
-impl std::error::Error for BlobDBError {}
diff --git a/services/blob/src/grpc.rs b/services/blob/src/grpc.rs
--- a/services/blob/src/grpc.rs
+++ b/services/blob/src/grpc.rs
@@ -13,7 +13,8 @@
GRPC_CHUNK_SIZE_LIMIT, GRPC_METADATA_SIZE_PER_MESSAGE,
MPSC_CHANNEL_BUFFER_CAPACITY, S3_MULTIPART_UPLOAD_MINIMUM_CHUNK_SIZE,
},
- database::{BlobItem, DatabaseClient, Error as DBError, ReverseIndexItem},
+ database::errors::Error as DBError,
+ database::old::{BlobItem, DatabaseClient, ReverseIndexItem},
s3::{MultiPartUploadSession, S3Client, S3Path},
tools::MemOps,
};
diff --git a/services/blob/src/http/context.rs b/services/blob/src/http/context.rs
--- a/services/blob/src/http/context.rs
+++ b/services/blob/src/http/context.rs
@@ -1,5 +1,5 @@
-use crate::database::ReverseIndexItem;
-use crate::database::{BlobItem, DatabaseClient, Error as DBError};
+use crate::database::errors::Error as DBError;
+use crate::database::old::{BlobItem, DatabaseClient, ReverseIndexItem};
use crate::s3::{Error as S3Error, S3Client, S3Path};
use actix_web::error::{
ErrorBadRequest, ErrorInternalServerError, ErrorNotFound,
diff --git a/services/blob/src/http/handlers/blob.rs b/services/blob/src/http/handlers/blob.rs
--- a/services/blob/src/http/handlers/blob.rs
+++ b/services/blob/src/http/handlers/blob.rs
@@ -1,7 +1,7 @@
use crate::constants::{
BLOB_DOWNLOAD_CHUNK_SIZE, S3_MULTIPART_UPLOAD_MINIMUM_CHUNK_SIZE,
};
-use crate::database::{BlobItem, ReverseIndexItem};
+use crate::database::old::{BlobItem, ReverseIndexItem};
use crate::http::context::handle_s3_error;
use crate::tools::MemOps;
use crate::validate_identifier;
diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs
--- a/services/blob/src/http/mod.rs
+++ b/services/blob/src/http/mod.rs
@@ -1,5 +1,5 @@
use crate::config::CONFIG;
-use crate::database::DatabaseClient;
+use crate::database::old::DatabaseClient;
use crate::s3::S3Client;
use actix_cors::Cors;
diff --git a/services/blob/src/main.rs b/services/blob/src/main.rs
--- a/services/blob/src/main.rs
+++ b/services/blob/src/main.rs
@@ -26,7 +26,7 @@
config::parse_cmdline_args()?;
let aws_config = config::load_aws_config().await;
- let db = database::DatabaseClient::new(&aws_config);
+ let db = database::old::DatabaseClient::new(&aws_config);
let s3 = s3::S3Client::new(&aws_config);
tokio::select! {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 7:09 PM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585857
Default Alt Text
D8440.diff (5 KB)
Attached To
Mode
D8440: [blob-service] Move database module to database/old
Attached
Detach File
Event Timeline
Log In to Comment