From 69516f1f6877a4de7dd92a758c83dd7ffc3254e3 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 12 Feb 2023 12:34:15 +0100 Subject: feat(tvix/store/blobservice): add GRPCBlobServiceWrapper This takes a BlobService and ChunkService in the constructor, and provides a [proto::blob_service_server::BlobService] trait for it. Implementing proto::blob_service_server::BlobService is a lot of surface to cover, and providing this wrapper will make individual implementations taking care of how to store chunks or chunking information much simpler. Change-Id: Ia7b46484fb3ac9104354d496ff2922dca96ff7b9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8092 Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/store/src/errors.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tvix/store/src/errors.rs') diff --git a/tvix/store/src/errors.rs b/tvix/store/src/errors.rs index 7f7474428400..25e87c8aa239 100644 --- a/tvix/store/src/errors.rs +++ b/tvix/store/src/errors.rs @@ -1,5 +1,6 @@ use std::sync::PoisonError; use thiserror::Error; +use tonic::Status; /// Errors related to communication with the store. #[derive(Debug, Error)] @@ -16,3 +17,12 @@ impl From> for Error { Error::StorageError(value.to_string()) } } + +impl From for Status { + fn from(value: Error) -> Self { + match value { + Error::InvalidRequest(msg) => Status::invalid_argument(msg), + Error::StorageError(msg) => Status::data_loss(format!("storage error: {}", msg)), + } + } +} -- cgit 1.4.1