about summary refs log tree commit diff
path: root/tvix/castore/src/blobservice/from_addr.rs
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2023-12-17T00·22+0100
committerclbot <clbot@tvl.fyi>2023-12-17T14·34+0000
commit0ae32d45f690eed8f259ac55b4d0d8bbc006baf2 (patch)
tree23d4b725053bf0a6bc5b41d79ce00a063c90cb38 /tvix/castore/src/blobservice/from_addr.rs
parent923a5737e61da020e6d7672c3aebc00db9f44850 (diff)
feat(tvix/castore): simple filesystem blob service r/7228
The simple filesystem `BlobService` enable a user to write blob store
on an existing filesystem using a prefix-style layout in the provided root directory,
e.g. the two first bytes of the blake3 hashes are used as directories prefixes.

Change-Id: I3451a688a6f39027b9c6517d853b95a87adb3a52
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10071
Autosubmit: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/castore/src/blobservice/from_addr.rs')
-rw-r--r--tvix/castore/src/blobservice/from_addr.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/tvix/castore/src/blobservice/from_addr.rs b/tvix/castore/src/blobservice/from_addr.rs
index 97e185464d3c..8f8e59952662 100644
--- a/tvix/castore/src/blobservice/from_addr.rs
+++ b/tvix/castore/src/blobservice/from_addr.rs
@@ -3,7 +3,9 @@ use url::Url;
 
 use crate::{proto::blob_service_client::BlobServiceClient, Error};
 
-use super::{BlobService, GRPCBlobService, MemoryBlobService, SledBlobService};
+use super::{
+    BlobService, GRPCBlobService, MemoryBlobService, SimpleFilesystemBlobService, SledBlobService,
+};
 
 /// Constructs a new instance of a [BlobService] from an URI.
 ///
@@ -11,6 +13,7 @@ use super::{BlobService, GRPCBlobService, MemoryBlobService, SledBlobService};
 /// - `memory://` ([MemoryBlobService])
 /// - `sled://` ([SledBlobService])
 /// - `grpc+*://` ([GRPCBlobService])
+/// - `simplefs://` ([SimpleFilesystemBlobService])
 ///
 /// See their `from_url` methods for more details about their syntax.
 pub async fn from_addr(uri: &str) -> Result<Arc<dyn BlobService>, crate::Error> {
@@ -54,6 +57,12 @@ pub async fn from_addr(uri: &str) -> Result<Arc<dyn BlobService>, crate::Error>
         // Constructing the channel is handled by tvix_castore::channel::from_url.
         let client = BlobServiceClient::new(crate::tonic::channel_from_url(&url).await?);
         Arc::new(GRPCBlobService::from_client(client))
+    } else if url.scheme() == "simplefs" {
+        if url.path().is_empty() {
+            return Err(Error::StorageError("Invalid filesystem path".to_string()));
+        }
+
+        Arc::new(SimpleFilesystemBlobService::new(url.path().into()).await?)
     } else {
         Err(crate::Error::StorageError(format!(
             "unknown scheme: {}",