pub struct SnapshotCache { /* private fields */ }Expand description
The last good ServedCatalog, when it was last assembled or attempted, and the clock that
decides when it is due. The clock lives here, never in handle.
Implementations§
Source§impl SnapshotCache
impl SnapshotCache
Sourcepub fn new(
served: ServedCatalog,
max_age: Duration,
clock: impl Fn() -> SystemTime + Send + Sync + 'static,
) -> Self
pub fn new( served: ServedCatalog, max_age: Duration, clock: impl Fn() -> SystemTime + Send + Sync + 'static, ) -> Self
Creates a cache holding served, assembled at clock(). The clock is the one now passed
to every re-assembly; production passes SystemTime::now.
Sourcepub async fn current(
&self,
store: &dyn CatalogStore,
catalog: &CatalogId,
) -> (Arc<ServedCatalog>, Option<ColdStartError>)
pub async fn current( &self, store: &dyn CatalogStore, catalog: &CatalogId, ) -> (Arc<ServedCatalog>, Option<ColdStartError>)
Returns the snapshot to serve, re-assembled when it is at least max_age old or the clock
has reached its next_expiry, so an expired lease is not
served past its expiry.
When re-assembly fails the last good snapshot is kept, which can hold a lease past its
expiry, and the failure is returned beside it so the caller can report it; the next
attempt waits another max_age.
Auto Trait Implementations§
impl !Freeze for SnapshotCache
impl !RefUnwindSafe for SnapshotCache
impl !UnwindSafe for SnapshotCache
impl Forget for SnapshotCache
impl Move for SnapshotCache
impl Send for SnapshotCache
impl Sync for SnapshotCache
impl Unpin for SnapshotCache
impl UnsafeUnpin for SnapshotCache
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.