refactor(tvix/store/pathinfo/sled): drop {blob,directory}_service
These are not used anymore. Change-Id: I9c348391c9600e9319f171faf3eda7175ebf7076 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11621 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
parent
03af6ab725
commit
a49c32ef42
2 changed files with 10 additions and 31 deletions
|
@ -65,10 +65,10 @@ pub async fn from_addr(
|
||||||
// TODO: expose other parameters as URL parameters?
|
// TODO: expose other parameters as URL parameters?
|
||||||
|
|
||||||
Box::new(if url.path().is_empty() {
|
Box::new(if url.path().is_empty() {
|
||||||
SledPathInfoService::new_temporary(blob_service, directory_service)
|
SledPathInfoService::new_temporary()
|
||||||
.map_err(|e| Error::StorageError(e.to_string()))?
|
.map_err(|e| Error::StorageError(e.to_string()))?
|
||||||
} else {
|
} else {
|
||||||
SledPathInfoService::new(url.path(), blob_service, directory_service)
|
SledPathInfoService::new(url.path())
|
||||||
.map_err(|e| Error::StorageError(e.to_string()))?
|
.map_err(|e| Error::StorageError(e.to_string()))?
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,57 +8,36 @@ use std::path::Path;
|
||||||
use tonic::async_trait;
|
use tonic::async_trait;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService, Error};
|
use tvix_castore::Error;
|
||||||
|
|
||||||
/// SledPathInfoService stores PathInfo in a [sled](https://github.com/spacejam/sled).
|
/// SledPathInfoService stores PathInfo in a [sled](https://github.com/spacejam/sled).
|
||||||
///
|
///
|
||||||
/// The PathInfo messages are stored as encoded protos, and keyed by their output hash,
|
/// The PathInfo messages are stored as encoded protos, and keyed by their output hash,
|
||||||
/// as that's currently the only request type available.
|
/// as that's currently the only request type available.
|
||||||
pub struct SledPathInfoService<BS, DS> {
|
pub struct SledPathInfoService {
|
||||||
db: sled::Db,
|
db: sled::Db,
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
blob_service: BS,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
directory_service: DS,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<BS, DS> SledPathInfoService<BS, DS> {
|
impl SledPathInfoService {
|
||||||
pub fn new<P: AsRef<Path>>(
|
pub fn new<P: AsRef<Path>>(p: P) -> Result<Self, sled::Error> {
|
||||||
p: P,
|
|
||||||
blob_service: BS,
|
|
||||||
directory_service: DS,
|
|
||||||
) -> Result<Self, sled::Error> {
|
|
||||||
let config = sled::Config::default()
|
let config = sled::Config::default()
|
||||||
.use_compression(false) // is a required parameter
|
.use_compression(false) // is a required parameter
|
||||||
.path(p);
|
.path(p);
|
||||||
let db = config.open()?;
|
let db = config.open()?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { db })
|
||||||
db,
|
|
||||||
blob_service,
|
|
||||||
directory_service,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_temporary(blob_service: BS, directory_service: DS) -> Result<Self, sled::Error> {
|
pub fn new_temporary() -> Result<Self, sled::Error> {
|
||||||
let config = sled::Config::default().temporary(true);
|
let config = sled::Config::default().temporary(true);
|
||||||
let db = config.open()?;
|
let db = config.open()?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { db })
|
||||||
db,
|
|
||||||
blob_service,
|
|
||||||
directory_service,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<BS, DS> PathInfoService for SledPathInfoService<BS, DS>
|
impl PathInfoService for SledPathInfoService {
|
||||||
where
|
|
||||||
BS: AsRef<dyn BlobService> + Send + Sync,
|
|
||||||
DS: AsRef<dyn DirectoryService> + Send + Sync,
|
|
||||||
{
|
|
||||||
#[instrument(level = "trace", skip_all, fields(path_info.digest = BASE64.encode(&digest)))]
|
#[instrument(level = "trace", skip_all, fields(path_info.digest = BASE64.encode(&digest)))]
|
||||||
async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> {
|
async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> {
|
||||||
let resp = tokio::task::spawn_blocking({
|
let resp = tokio::task::spawn_blocking({
|
||||||
|
|
Loading…
Reference in a new issue