Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33310426
D5700.1768807979.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D5700.1768807979.diff
View Options
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
--- a/services/blob/src/constants.rs
+++ b/services/blob/src/constants.rs
@@ -3,6 +3,26 @@
pub const GRPC_SERVER_DEFAULT_PORT: u64 = 50051;
pub const AWS_REGION: &str = "us-east-2";
pub const LOCALSTACK_URL: &str = "http://localhost:4566";
+pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1;
+
+/// 4MB limit
+///
+/// WARNING: use keeping in mind that grpc adds its own headers to messages
+/// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
+/// so the message that actually is being sent over the network looks like this
+/// ```
+/// [Compressed-Flag] [Message-Length] [Message]
+/// [Compressed-Flag] 1 byte - added by grpc
+/// [Message-Length] 4 bytes - added by grpc
+/// [Message] N bytes - actual data
+/// ```
+/// so for every message we get 5 additional bytes of data
+/// as [mentioned here](https://github.com/grpc/grpc/issues/15734#issuecomment-396962671),
+/// gRPC stream may contain more than one message
+pub const GRPC_CHUNK_SIZE_LIMIT: u64 = 4 * 1024 * 1024;
+
+/// See [`GRPC_CHUNK_SIZE_LIMIT`] description for details
+pub const GRPC_METADATA_SIZE_PER_MESSAGE: u64 = 5;
// DynamoDB constants
diff --git a/services/blob/src/service.rs b/services/blob/src/service.rs
--- a/services/blob/src/service.rs
+++ b/services/blob/src/service.rs
@@ -4,7 +4,10 @@
use tokio_stream::Stream;
use tonic::{Request, Response, Status};
-use crate::database::DatabaseClient;
+use crate::{
+ database::{BlobItem, DatabaseClient, ReverseIndexItem},
+ s3::S3Path,
+};
pub mod blob {
tonic::include_proto!("blob");
@@ -22,6 +25,31 @@
s3: Arc::new(s3_client),
}
}
+
+ async fn find_s3_path_by_reverse_index(
+ &self,
+ reverse_index_item: &ReverseIndexItem,
+ ) -> Result<S3Path, Status> {
+ let blob_hash = &reverse_index_item.blob_hash;
+ match self.db.find_blob_item(&blob_hash).await {
+ Ok(Some(BlobItem { s3_path, .. })) => Ok(s3_path),
+ Ok(None) => Err(Status::not_found("blob not found")),
+ Err(_) => Err(Status::aborted("internal error")),
+ }
+ }
+
+ async fn find_s3_path_by_holder(
+ &self,
+ holder: &str,
+ ) -> Result<S3Path, Status> {
+ match self.db.find_reverse_index_by_holder(holder).await {
+ Ok(Some(reverse_index)) => {
+ self.find_s3_path_by_reverse_index(&reverse_index).await
+ }
+ Ok(None) => Err(Status::not_found("blob not found")),
+ Err(_) => Err(Status::aborted("internal error")),
+ }
+ }
}
// gRPC implementation
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 7:32 AM (17 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5955178
Default Alt Text
D5700.1768807979.diff (2 KB)
Attached To
Mode
D5700: [services][blob] Add helpers and constants for Get RPC
Attached
Detach File
Event Timeline
Log In to Comment