Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

A ConversationStore kept in memory, for runtime tests.

Implementations§

Source§

impl MemoryStore

Source

pub fn new(clock: Arc<dyn Clock>) -> Self

An empty store reading time from clock.

Source

pub fn runs(&self) -> Vec<AgentRunRecord>

Recorded agent runs, oldest first.

Trait Implementations§

Source§

impl ConversationStore for MemoryStore

Source§

fn mark_seen<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, event_id: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Records an inbound event id. Returns false when it was already seen within ttl.
Source§

fn append<'life0, 'async_trait>( &'life0 self, message: NewMessage, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Appends a message to a conversation.
Source§

fn recent<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredMessage>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The newest limit messages after the last reset, oldest first.
Source§

fn reset<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Starts a fresh history for the conversation (/reset). Old messages stay for audit until retention removes them.
Source§

fn session<'life0, 'life1, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<Option<(String, String)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The native agent session of a conversation: (backend, session id).
Source§

fn set_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, conversation: &'life1 ConversationKey, backend: &'life2 str, session: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remembers the native agent session of a conversation (cleared by ConversationStore::reset).
Source§

fn owners<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<(ChannelId, UserId)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accounts of the owner of a personal bot (paired with ConversationStore::redeem_pairing_code).
Source§

fn remove_owner<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Removes an owner account. Returns whether it was one.
Source§

fn create_pairing_code<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores a one-time pairing code, valid for ttl.
Source§

fn redeem_pairing_code<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, code: &'life1 str, channel: &'life2 ChannelId, user: &'life3 UserId, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Consumes code and makes (channel, user) an owner account when the code is valid. Read more
Source§

fn record_run<'life0, 'async_trait>( &'life0 self, run: AgentRunRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records an agent run.
Source§

fn claim_fire<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, fire_at: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<Fire, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Claims a task firing: records it as FireState::Sending the first time and returns its current record, so a firing that was already sent is never sent again.
Source§

fn set_fire<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, fire_at: Timestamp, state: FireState, attempts: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates a claimed firing.
Source§

fn recent_fires<'life0, 'async_trait>( &'life0 self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Fire>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The newest limit firings, newest first (for okbot doctor and okbot task).
Source§

fn set_direct_chat<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, conversation: &'life3 ConversationKey, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remembers the direct conversation of user on channel (reminders sent there).
Source§

fn direct_chat<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, channel: &'life1 ChannelId, user: &'life2 UserId, ) -> Pin<Box<dyn Future<Output = Result<Option<ConversationKey>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The latest direct conversation of user on channel.
Source§

fn purge_before<'life0, 'async_trait>( &'life0 self, before: Timestamp, ) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Deletes messages, runs, dedupe marks and finished firings older than before. Returns rows removed.
Source§

impl Debug for MemoryStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.