Struct tvix_castore::import::blobs::ConcurrentBlobUploader
source · pub struct ConcurrentBlobUploader<BS> {
blob_service: BS,
upload_tasks: JoinSet<Result<(), Error>>,
upload_semaphore: Arc<Semaphore>,
}
Expand description
The concurrent blob uploader provides a mechanism for concurrently uploading small blobs. This is useful when ingesting from sources like tarballs and archives which each blob entry must be read sequentially. Ingesting many small blobs sequentially becomes slow due to round trip time with the blob service. The concurrent blob uploader will buffer small blobs in memory and upload them to the blob service in the background.
Once all blobs have been uploaded, make sure to call ConcurrentBlobUploader::join to wait for all background jobs to complete and check for any errors.
Fields§
§blob_service: BS
§upload_tasks: JoinSet<Result<(), Error>>
§upload_semaphore: Arc<Semaphore>
Implementations§
source§impl<BS> ConcurrentBlobUploader<BS>where
BS: BlobService + Clone + 'static,
impl<BS> ConcurrentBlobUploader<BS>where
BS: BlobService + Clone + 'static,
sourcepub fn new(blob_service: BS) -> Self
pub fn new(blob_service: BS) -> Self
Creates a new concurrent blob uploader which uploads blobs to the provided blob service.
sourcepub async fn upload<R>(
&mut self,
path: &Path,
expected_size: u64,
r: R,
) -> Result<B3Digest, Error>
pub async fn upload<R>( &mut self, path: &Path, expected_size: u64, r: R, ) -> Result<B3Digest, Error>
Uploads a blob to the blob service. If the blob is small enough it will be read to a buffer and uploaded in the background. This will read the entirety of the provided reader unless an error occurs, even if blobs are uploaded in the background..
Auto Trait Implementations§
impl<BS> Freeze for ConcurrentBlobUploader<BS>where
BS: Freeze,
impl<BS> RefUnwindSafe for ConcurrentBlobUploader<BS>where
BS: RefUnwindSafe,
impl<BS> Send for ConcurrentBlobUploader<BS>where
BS: Send,
impl<BS> Sync for ConcurrentBlobUploader<BS>where
BS: Sync,
impl<BS> Unpin for ConcurrentBlobUploader<BS>where
BS: Unpin,
impl<BS> UnwindSafe for ConcurrentBlobUploader<BS>where
BS: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request