pub struct RunExportsCache { /* private fields */ }Expand description
A RunExportsCache manages a cache of run_exports.json
The store does not provide an implementation to get the data into the store.
Instead, this is left up to the user when the run_exports.json is requested. If the
run_exports.json is found in the cache it is returned immediately. However, if the
cache is missing a user defined function is called to populate the cache. This
separates the corners between caching and fetching of the content.
Implementations§
Source§impl RunExportsCache
impl RunExportsCache
Sourcepub fn new(path: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>) -> Self
Constructs a new RunExportsCache located at the specified path.
Sourcepub async fn get_or_fetch<F, Fut, E>(
&self,
cache_key: &CacheKey,
fetch: F,
) -> Result<CacheEntry, RunExportsCacheError>
pub async fn get_or_fetch<F, Fut, E>( &self, cache_key: &CacheKey, fetch: F, ) -> Result<CacheEntry, RunExportsCacheError>
Returns the directory that contains the specified package.
If the package was previously successfully fetched and stored in the
cache the directory containing the data is returned immediately. If
the package was not previously fetch the filesystem is checked to
see if a directory with valid package content exists. Otherwise, the
user provided fetch function is called to populate the cache.
If the package is already being fetched by another task/thread the request is coalesced. No duplicate fetch is performed.
Sourcepub async fn get_or_fetch_from_url(
&self,
cache_key: &CacheKey,
url: Url,
client: ClientWithMiddleware,
reporter: Option<Arc<dyn CacheReporter>>,
) -> Result<CacheEntry, RunExportsCacheError>
pub async fn get_or_fetch_from_url( &self, cache_key: &CacheKey, url: Url, client: ClientWithMiddleware, reporter: Option<Arc<dyn CacheReporter>>, ) -> Result<CacheEntry, RunExportsCacheError>
Returns the directory that contains the specified package.
This is a convenience wrapper around get_or_fetch which fetches the
package from the given URL if the package could not be found in the
cache.
Sourcepub async fn get_or_fetch_from_url_with_retry(
&self,
cache_key: &CacheKey,
url: Url,
client: ClientWithMiddleware,
retry_policy: impl RetryPolicy + Send + 'static + Clone,
reporter: Option<Arc<dyn CacheReporter>>,
) -> Result<CacheEntry, RunExportsCacheError>
pub async fn get_or_fetch_from_url_with_retry( &self, cache_key: &CacheKey, url: Url, client: ClientWithMiddleware, retry_policy: impl RetryPolicy + Send + 'static + Clone, reporter: Option<Arc<dyn CacheReporter>>, ) -> Result<CacheEntry, RunExportsCacheError>
Returns the directory that contains the specified package.
This is a convenience wrapper around get_or_fetch which fetches the
package from the given URL if the package could not be found in the
cache.
This function assumes that the client is already configured with a
retry middleware that will retry any request that fails. This function
uses the passed in retry_policy if, after the request has been sent
and the response is successful, streaming of the package data fails
and the whole request must be retried.
Trait Implementations§
Source§impl Clone for RunExportsCache
impl Clone for RunExportsCache
Source§fn clone(&self) -> RunExportsCache
fn clone(&self) -> RunExportsCache
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RunExportsCache
impl !RefUnwindSafe for RunExportsCache
impl Send for RunExportsCache
impl Sync for RunExportsCache
impl Unpin for RunExportsCache
impl !UnwindSafe for RunExportsCache
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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 more