about summary refs log tree commit diff
path: root/tvix/store/src/main.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2022-12-28T15·40+0100
committerflokli <flokli@flokli.de>2022-12-30T15·21+0000
commit58f5ff2c173b6c64e3ffb1d2cd4d840e0dcf38c3 (patch)
treeaf3e28b373a54e50b3e72a803eae779a633a9f20 /tvix/store/src/main.rs
parentd22a9c8610f2cd1bf0e021ec1f46e6200ed4a28f (diff)
feat(tvix/store): initial dummy implementation r/5554
This replaces the hello world example from tvix-store with an actual
gRPC endpoint, implementing all of BlobService, DirectoryService and
PathInfoService.

All RPC methods currently respond with the unimplemented gRPC status.

Co-Authored-By: Márton Boros <martonboros@gmail.com>
Change-Id: Ieba333cca44dc1e3f2ffbe676ba7a99e672b9bfb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7664
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/main.rs')
-rw-r--r--tvix/store/src/main.rs42
1 files changed, 40 insertions, 2 deletions
diff --git a/tvix/store/src/main.rs b/tvix/store/src/main.rs
index c7823b87e468..cc9002438bce 100644
--- a/tvix/store/src/main.rs
+++ b/tvix/store/src/main.rs
@@ -1,3 +1,13 @@
+use crate::proto::blob_service_server::BlobServiceServer;
+use crate::proto::directory_service_server::DirectoryServiceServer;
+use crate::proto::path_info_service_server::PathInfoServiceServer;
+
+use clap::Parser;
+use tonic::{transport::Server, Result};
+
+mod dummy_blob_service;
+mod dummy_directory_service;
+mod dummy_path_info_service;
 mod nixbase32;
 mod nixpath;
 mod proto;
@@ -5,6 +15,34 @@ mod proto;
 #[cfg(test)]
 mod tests;
 
-fn main() {
-    println!("Hello, world!");
+#[derive(Parser)]
+#[command(author, version, about, long_about = None)]
+struct Cli {
+    #[clap(long, short = 'l')]
+    listen_address: Option<String>,
+}
+
+#[tokio::main]
+async fn main() -> Result<(), Box<dyn std::error::Error>> {
+    let cli = Cli::parse();
+    let listen_address = cli
+        .listen_address
+        .unwrap_or("[::]:8000".to_string())
+        .parse()
+        .unwrap();
+
+    let blob_service = dummy_blob_service::DummyBlobService {};
+    let directory_service = dummy_directory_service::DummyDirectoryService {};
+    let path_info_service = dummy_path_info_service::DummyPathInfoService {};
+
+    println!("tvix-store listening on {}", listen_address);
+
+    Server::builder()
+        .add_service(BlobServiceServer::new(blob_service))
+        .add_service(DirectoryServiceServer::new(directory_service))
+        .add_service(PathInfoServiceServer::new(path_info_service))
+        .serve(listen_address)
+        .await?;
+
+    Ok(())
 }