refactor(tvix/store): use Arc instead of Box
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>
This commit is contained in:
parent
7725eb53ad
commit
aa7bdc1199
13 changed files with 132 additions and 108 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue