Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3530246
D5677.id18799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5677.id18799.diff
View Options
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
new file mode 100644
--- /dev/null
+++ b/services/blob/src/constants.rs
@@ -0,0 +1 @@
+pub const GRPC_SERVER_DEFAULT_PORT: u64 = 50051;
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
@@ -1,8 +1,26 @@
+pub mod constants;
pub mod service;
use anyhow::Result;
+use service::{blob::blob_service_server::BlobServiceServer, MyBlobService};
+use std::net::SocketAddr;
+use tonic::transport::Server;
+
+async fn run_grpc_server() -> Result<()> {
+ let addr: SocketAddr =
+ format!("[::]:{}", constants::GRPC_SERVER_DEFAULT_PORT).parse()?;
+ let blob_service = MyBlobService::default();
+
+ println!("Starting gRPC server at port {}", addr.port());
+ Server::builder()
+ .add_service(BlobServiceServer::new(blob_service))
+ .serve(addr)
+ .await?;
-fn main() -> Result<()> {
- println!("Hello world");
Ok(())
}
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ run_grpc_server().await
+}
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
@@ -1,3 +1,41 @@
+use anyhow::Result;
+use blob::blob_service_server::BlobService;
+use std::pin::Pin;
+use tokio_stream::Stream;
+use tonic::{Request, Response, Status};
+
pub mod blob {
tonic::include_proto!("blob");
}
+
+#[derive(Default)]
+pub struct MyBlobService {}
+
+// gRPC implementation
+#[tonic::async_trait]
+impl BlobService for MyBlobService {
+ type PutStream =
+ Pin<Box<dyn Stream<Item = Result<blob::PutResponse, Status>> + Send>>;
+ async fn put(
+ &self,
+ _request: Request<tonic::Streaming<blob::PutRequest>>,
+ ) -> Result<Response<Self::PutStream>, Status> {
+ Err(Status::unimplemented("Not implemented yet"))
+ }
+
+ type GetStream =
+ Pin<Box<dyn Stream<Item = Result<blob::GetResponse, Status>> + Send>>;
+ async fn get(
+ &self,
+ _request: Request<blob::GetRequest>,
+ ) -> Result<Response<Self::GetStream>, Status> {
+ Err(Status::unimplemented("Not implemented yet"))
+ }
+
+ async fn remove(
+ &self,
+ _request: Request<blob::RemoveRequest>,
+ ) -> Result<Response<()>, Status> {
+ Err(Status::unimplemented("Not implemented yet"))
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 1:37 AM (7 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703031
Default Alt Text
D5677.id18799.diff (2 KB)
Attached To
Mode
D5677: [services][blob] Scaffold gRPC server
Attached
Detach File
Event Timeline
Log In to Comment