pub struct PostgresCheckpointer { /* private fields */ }postgres only.Expand description
Durable PostgreSQL checkpointer that retains the full step history.
Storage grows with session count and step depth. For long-lived deployments
use periodic SQL maintenance — for example, delete steps older than N days
or keep only the most recent M steps per session, then VACUUM ANALYZE.
Implementations§
Source§impl PostgresCheckpointer
impl PostgresCheckpointer
Sourcepub async fn connect(database_url: &str) -> Result<Self, CheckpointerError>
pub async fn connect(database_url: &str) -> Result<Self, CheckpointerError>
Open a connection pool to database_url and return a ready checkpointer.
When the postgres-migrations feature is enabled, embedded migrations
are applied automatically (idempotent).
Source§impl PostgresCheckpointer
impl PostgresCheckpointer
Sourcepub async fn query_steps(
&self,
session_id: &str,
query: StepQuery,
) -> Result<StepQueryResult>
pub async fn query_steps( &self, session_id: &str, query: StepQuery, ) -> Result<StepQueryResult>
Query the full step history for a session with optional filters and pagination.
Results are ordered by step number descending. limit defaults to 100 and
is capped at 1 000. The total record count before pagination is reported in
PageInfo::total_count.
§Example
use weavegraph::runtimes::checkpointer_postgres::{PostgresCheckpointer, StepQuery};
let cp = PostgresCheckpointer::connect("postgresql://localhost/app").await?;
let result = cp.query_steps("my-session", StepQuery {
limit: Some(25),
min_step: Some(10),
..Default::default()
}).await?;
println!("{} total, {} on page", result.page_info.total_count, result.page_info.page_size);Sourcepub async fn save_with_concurrency_check(
&self,
checkpoint: Checkpoint,
expected_last_step: Option<u64>,
) -> Result<()>
pub async fn save_with_concurrency_check( &self, checkpoint: Checkpoint, expected_last_step: Option<u64>, ) -> Result<()>
Save a checkpoint only when sessions.last_step equals expected_last_step.
Uses SELECT … FOR UPDATE to serialize concurrent writers. Pass None to
skip the check (equivalent to Checkpointer::save).
§Example
use weavegraph::runtimes::checkpointer_postgres::PostgresCheckpointer;
let cp = PostgresCheckpointer::connect("postgresql://localhost/app").await?;
cp.save_with_concurrency_check(checkpoint, Some(4)).await?;Trait Implementations§
Source§impl Checkpointer for PostgresCheckpointer
impl Checkpointer for PostgresCheckpointer
Source§fn save<'life0, 'async_trait>(
&'life0 self,
checkpoint: Checkpoint,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn save<'life0, 'async_trait>(
&'life0 self,
checkpoint: Checkpoint,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn load_latest<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_latest<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
None if absent.Auto Trait Implementations§
impl !RefUnwindSafe for PostgresCheckpointer
impl !UnwindSafe for PostgresCheckpointer
impl Freeze for PostgresCheckpointer
impl Send for PostgresCheckpointer
impl Sync for PostgresCheckpointer
impl Unpin for PostgresCheckpointer
impl UnsafeUnpin for PostgresCheckpointer
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
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> 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