pub struct PostgresStore { /* private fields */ }Implementations§
Source§impl PostgresStore
impl PostgresStore
Sourcepub fn new(pool: PgPool) -> Self
pub fn new(pool: PgPool) -> Self
Create a new PostgreSQL storage using the given connection pool.
Sessions are stored in the agent_sessions table by default,
messages in agent_messages.
Sourcepub fn with_table(pool: PgPool, table: impl Into<String>) -> Self
pub fn with_table(pool: PgPool, table: impl Into<String>) -> Self
Create a new PostgreSQL storage with a custom table name.
The messages table will be named {table}_messages.
Sourcepub async fn ensure_table(&self) -> Result<(), ThreadStoreError>
pub async fn ensure_table(&self) -> Result<(), ThreadStoreError>
Ensure the storage tables exist (idempotent).
This is optional for callers; the store also initializes its schema automatically on first access.
Trait Implementations§
Source§impl MailboxReader for PostgresStore
impl MailboxReader for PostgresStore
fn load_mailbox_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_mailbox_state<'life0, 'life1, 'async_trait>(
&'life0 self,
mailbox_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MailboxState>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_mailbox_entries<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MailboxQuery,
) -> Pin<Box<dyn Future<Output = Result<MailboxPage, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl MailboxWriter for PostgresStore
impl MailboxWriter for PostgresStore
fn enqueue_mailbox_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
entry: &'life1 MailboxEntry,
) -> Pin<Box<dyn Future<Output = Result<(), MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ensure_mailbox_state<'life0, 'life1, 'async_trait>(
&'life0 self,
mailbox_id: &'life1 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<MailboxState, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn claim_mailbox_entries<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
mailbox_id: Option<&'life1 str>,
limit: usize,
consumer_id: &'life2 str,
now: u64,
lease_duration_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn claim_mailbox_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
consumer_id: &'life2 str,
now: u64,
lease_duration_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn ack_mailbox_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
claim_token: &'life2 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<(), MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn nack_mailbox_entry<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
claim_token: &'life2 str,
retry_at: u64,
error: &'life3 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<(), MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn dead_letter_mailbox_entry<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
claim_token: &'life2 str,
error: &'life3 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<(), MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn cancel_mailbox_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn supersede_mailbox_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
now: u64,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cancel_pending_for_mailbox<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
mailbox_id: &'life1 str,
now: u64,
exclude_entry_id: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<MailboxEntry>, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn interrupt_mailbox<'life0, 'life1, 'async_trait>(
&'life0 self,
mailbox_id: &'life1 str,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<MailboxInterrupt, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn extend_lease<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
claim_token: &'life2 str,
extension_ms: u64,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn extend_lease<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 str,
claim_token: &'life2 str,
extension_ms: u64,
now: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Extend the lease on a claimed entry. Read more
Source§fn purge_terminal_mailbox_entries<'life0, 'async_trait>(
&'life0 self,
older_than: u64,
) -> Pin<Box<dyn Future<Output = Result<usize, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_terminal_mailbox_entries<'life0, 'async_trait>(
&'life0 self,
older_than: u64,
) -> Pin<Box<dyn Future<Output = Result<usize, MailboxStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete terminal entries older than
older_than (unix millis). Returns count deleted.Source§impl RunReader for PostgresStore
impl RunReader for PostgresStore
Source§fn load_run<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_run<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load one run by run id.
Source§fn list_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 RunQuery,
) -> Pin<Box<dyn Future<Output = Result<RunPage, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 RunQuery,
) -> Pin<Box<dyn Future<Output = Result<RunPage, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List runs with optional filtering and pagination.
Source§fn resolve_thread_id<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve_thread_id<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve thread id from run id.
Source§fn load_current_run<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_current_run<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, RunStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the most recent non-terminal run for a thread, if any. Read more
Source§impl RunWriter for PostgresStore
impl RunWriter for PostgresStore
Source§impl ThreadReader for PostgresStore
impl ThreadReader for PostgresStore
Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ThreadHead>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ThreadHead>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load an Thread and its current version.
Source§fn load_messages<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
query: &'life2 MessageQuery,
) -> Pin<Box<dyn Future<Output = Result<MessagePage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn load_messages<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
query: &'life2 MessageQuery,
) -> Pin<Box<dyn Future<Output = Result<MessagePage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Load paginated messages for an Thread.
Source§fn message_count<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn message_count<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<usize, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return total message count.
Source§fn list_threads<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ThreadListQuery,
) -> Pin<Box<dyn Future<Output = Result<ThreadListPage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_threads<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ThreadListQuery,
) -> Pin<Box<dyn Future<Output = Result<ThreadListPage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List Thread ids.
Source§fn load_run<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_run<'life0, 'life1, 'async_trait>(
&'life0 self,
run_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load one run record by run id.
Source§fn list_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 RunQuery,
) -> Pin<Box<dyn Future<Output = Result<RunPage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 RunQuery,
) -> Pin<Box<dyn Future<Output = Result<RunPage, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List runs with optional filtering and pagination.
Source§fn active_run_for_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn active_run_for_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the most recent non-terminal run for a thread, if any.
Source§fn load_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Thread>, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn load_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Thread>, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Load an Thread without version info. Convenience wrapper.
Source§fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
List all Thread ids with default paging.
Source§fn list_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ThreadListQuery,
) -> Pin<Box<dyn Future<Output = Result<ThreadListPage, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn list_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ThreadListQuery,
) -> Pin<Box<dyn Future<Output = Result<ThreadListPage, ThreadStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
List Thread ids with explicit query.
Source§impl ThreadWriter for PostgresStore
impl ThreadWriter for PostgresStore
Source§fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
thread: &'life1 Thread,
) -> Pin<Box<dyn Future<Output = Result<Committed, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
thread: &'life1 Thread,
) -> Pin<Box<dyn Future<Output = Result<Committed, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new Thread.
Source§fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
delta: &'life2 ThreadChangeSet,
precondition: VersionPrecondition,
) -> Pin<Box<dyn Future<Output = Result<Committed, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
thread_id: &'life1 str,
delta: &'life2 ThreadChangeSet,
precondition: VersionPrecondition,
) -> Pin<Box<dyn Future<Output = Result<Committed, ThreadStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append an ThreadChangeSet to an existing Thread.
Auto Trait Implementations§
impl !Freeze for PostgresStore
impl !RefUnwindSafe for PostgresStore
impl Send for PostgresStore
impl Sync for PostgresStore
impl Unpin for PostgresStore
impl !UnwindSafe for PostgresStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more