feat(tvix/store/bin): use sled for daemon, grpc for import cmd
This now creates different store client, depending on the cli subcommand. The `import` command will connect to the gRPC service, and the `daemon` command will use the sled implementation. It might make sense to define some URI syntax to make this configurable by the user, via the CLI. Change-Id: I72351fcf0e83a013b6aa67a90b64c108cbb01ffd Reviewed-on: https://cl.tvl.fyi/c/depot/+/8619 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
e3c5eb3313
commit
2b0b4cadbd
1 changed files with 23 additions and 8 deletions
|
@ -6,13 +6,20 @@ use std::path::Path;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tvix_store::blobservice::GRPCBlobService;
|
||||
use tvix_store::blobservice::SledBlobService;
|
||||
use tvix_store::directoryservice::GRPCDirectoryService;
|
||||
use tvix_store::directoryservice::SledDirectoryService;
|
||||
use tvix_store::nar::GRPCNARCalculationService;
|
||||
use tvix_store::nar::NonCachingNARCalculationService;
|
||||
use tvix_store::pathinfoservice::GRPCPathInfoService;
|
||||
use tvix_store::pathinfoservice::SledPathInfoService;
|
||||
use tvix_store::proto::blob_service_client::BlobServiceClient;
|
||||
use tvix_store::proto::blob_service_server::BlobServiceServer;
|
||||
use tvix_store::proto::directory_service_client::DirectoryServiceClient;
|
||||
use tvix_store::proto::directory_service_server::DirectoryServiceServer;
|
||||
use tvix_store::proto::node::Node;
|
||||
use tvix_store::proto::path_info_service_client::PathInfoServiceClient;
|
||||
use tvix_store::proto::path_info_service_server::PathInfoServiceServer;
|
||||
use tvix_store::proto::GRPCBlobServiceWrapper;
|
||||
use tvix_store::proto::GRPCDirectoryServiceWrapper;
|
||||
|
@ -83,13 +90,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
tracing::subscriber::set_global_default(subscriber).expect("Unable to set global subscriber");
|
||||
|
||||
match cli.command {
|
||||
Commands::Daemon { listen_address } => {
|
||||
// initialize stores
|
||||
let blob_service = SledBlobService::new("blobs.sled".into())?;
|
||||
let directory_service = SledDirectoryService::new("directories.sled".into())?;
|
||||
let path_info_service = SledPathInfoService::new("pathinfo.sled".into())?;
|
||||
|
||||
match cli.command {
|
||||
Commands::Daemon { listen_address } => {
|
||||
let listen_address = listen_address
|
||||
.unwrap_or_else(|| "[::]:8000".to_string())
|
||||
.parse()
|
||||
|
@ -128,10 +135,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
router.serve(listen_address).await?;
|
||||
}
|
||||
Commands::Import { paths } => {
|
||||
let nar_calculation_service = NonCachingNARCalculationService::new(
|
||||
blob_service.clone(),
|
||||
directory_service.clone(),
|
||||
let blob_service = GRPCBlobService::from_client(
|
||||
BlobServiceClient::connect("http://[::1]:8000").await?,
|
||||
);
|
||||
let directory_service = GRPCDirectoryService::from_client(
|
||||
DirectoryServiceClient::connect("http://[::1]:8000").await?,
|
||||
);
|
||||
let path_info_service_client =
|
||||
PathInfoServiceClient::connect("http://[::1]:8000").await?;
|
||||
let path_info_service =
|
||||
GRPCPathInfoService::from_client(path_info_service_client.clone());
|
||||
let nar_calculation_service =
|
||||
GRPCNARCalculationService::from_client(path_info_service_client);
|
||||
|
||||
let io = Arc::new(TvixStoreIO::new(
|
||||
blob_service,
|
||||
|
|
Loading…
Reference in a new issue