about summary refs log tree commit diff
path: root/tvix/store/src/proto
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-06-09T15·22+0300
committerclbot <clbot@tvl.fyi>2023-06-12T10·24+0000
commitaa7bdc1199bfbb69091dda942a82812257e30bc4 (patch)
tree933964562f5746274ef6df59cfa956aca73b0807 /tvix/store/src/proto
parent7725eb53ad67730e92a3839a6c10925c668e5586 (diff)
refactor(tvix/store): use Arc instead of Box r/6273
This allows us to blob services without closing them before putting them
in a box.
We currently need to use Arc<_>, not Rc<_>, because the GRPC wrappers
require Sync.

Change-Id: I679c5f06b62304f5b0456cfefe25a0a881de7c84
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8738
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/proto')
-rw-r--r--tvix/store/src/proto/grpc_blobservice_wrapper.rs8
-rw-r--r--tvix/store/src/proto/grpc_directoryservice_wrapper.rs8
2 files changed, 8 insertions, 8 deletions
diff --git a/tvix/store/src/proto/grpc_blobservice_wrapper.rs b/tvix/store/src/proto/grpc_blobservice_wrapper.rs
index 066790daf370..f1ab3a87e477 100644
--- a/tvix/store/src/proto/grpc_blobservice_wrapper.rs
+++ b/tvix/store/src/proto/grpc_blobservice_wrapper.rs
@@ -1,7 +1,7 @@
 use crate::{
     blobservice::BlobService, proto::sync_read_into_async_read::SyncReadIntoAsyncRead, B3Digest,
 };
-use std::{collections::VecDeque, io, pin::Pin};
+use std::{collections::VecDeque, io, pin::Pin, sync::Arc};
 use tokio::task;
 use tokio_stream::StreamExt;
 use tokio_util::io::ReaderStream;
@@ -9,11 +9,11 @@ use tonic::{async_trait, Request, Response, Status, Streaming};
 use tracing::{instrument, warn};
 
 pub struct GRPCBlobServiceWrapper {
-    blob_service: Box<dyn BlobService>,
+    blob_service: Arc<dyn BlobService>,
 }
 
-impl From<Box<dyn BlobService + 'static>> for GRPCBlobServiceWrapper {
-    fn from(value: Box<dyn BlobService>) -> Self {
+impl From<Arc<dyn BlobService>> for GRPCBlobServiceWrapper {
+    fn from(value: Arc<dyn BlobService>) -> Self {
         Self {
             blob_service: value,
         }
diff --git a/tvix/store/src/proto/grpc_directoryservice_wrapper.rs b/tvix/store/src/proto/grpc_directoryservice_wrapper.rs
index f27688c4e962..434d660f3d41 100644
--- a/tvix/store/src/proto/grpc_directoryservice_wrapper.rs
+++ b/tvix/store/src/proto/grpc_directoryservice_wrapper.rs
@@ -8,13 +8,13 @@ use tonic::{async_trait, Request, Response, Status, Streaming};
 use tracing::{debug, instrument, warn};
 
 pub struct GRPCDirectoryServiceWrapper {
-    directory_service: Arc<Box<dyn DirectoryService>>,
+    directory_service: Arc<dyn DirectoryService>,
 }
 
-impl From<Box<dyn DirectoryService>> for GRPCDirectoryServiceWrapper {
-    fn from(value: Box<dyn DirectoryService>) -> Self {
+impl From<Arc<dyn DirectoryService>> for GRPCDirectoryServiceWrapper {
+    fn from(value: Arc<dyn DirectoryService>) -> Self {
         Self {
-            directory_service: Arc::new(value),
+            directory_service: value,
         }
     }
 }