pub struct InMemoryBackend { /* private fields */ }Expand description
Single-process, Mutex-guarded. Rejects stale fetches so the same semantics as the Postgres impl hold in tests.
Implementations§
Trait Implementations§
Source§impl Debug for InMemoryBackend
impl Debug for InMemoryBackend
Source§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§fn default() -> InMemoryBackend
fn default() -> InMemoryBackend
Returns the “default value” for a type. Read more
Source§impl PersistenceBackend for InMemoryBackend
impl PersistenceBackend for InMemoryBackend
Source§fn persist<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: &'life2 CognitiveState,
ttl: ChronoDuration,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn persist<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: &'life2 CognitiveState,
ttl: ChronoDuration,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Persist the state under
session_id. ttl is advisory; the
backend is free to honour it via a scheduled eviction job
(the Postgres impl) or a best-effort timer (in-memory).Source§fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<CognitiveState, PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn restore<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<CognitiveState, PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch a previously persisted state. Returns
PersistenceError::NotFound when no record exists and
PersistenceError::Expired when one exists but its TTL
lapsed.Source§fn evict<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn evict<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Irreversibly delete the state. Idempotent — no-op when the
session has no stored state.
Source§fn evict_expired<'life0, 'async_trait>(
&'life0 self,
before: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<u64, PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn evict_expired<'life0, 'async_trait>(
&'life0 self,
before: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<u64, PersistenceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Evict every state whose TTL lapsed at or before
before.
Returns the count of rows removed for observability. Called
periodically by the eviction worker in production; in-memory
impl sweeps on-demand.Auto Trait Implementations§
impl !Freeze for InMemoryBackend
impl RefUnwindSafe for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl UnwindSafe for InMemoryBackend
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.