pub struct PostgresIncrementalBackend { /* private fields */ }Expand description
PostgreSQL storage backend for the incremental update system.
Uses deadpool-postgres for connection pooling and tokio-postgres for
async query execution. All queries use prepared statements for optimal
query plan caching.
§Connection Management
The backend manages a pool of connections. The default pool size is 16 connections, configurable via the connection URL or pool configuration.
§Thread Safety
This type is Send + Sync and can be shared across async tasks.
Implementations§
Source§impl PostgresIncrementalBackend
impl PostgresIncrementalBackend
Sourcepub async fn new(database_url: &str) -> Result<Self, StorageError>
pub async fn new(database_url: &str) -> Result<Self, StorageError>
Creates a new Postgres backend connected to the given database URL.
The URL should be a standard PostgreSQL connection string:
postgresql://user:password@host:port/database
§Arguments
database_url- PostgreSQL connection string.
§Errors
Returns StorageError::Backend if the connection pool cannot be created.
§Examples
let backend = PostgresIncrementalBackend::new("postgresql://localhost/thread").await?;Sourcepub fn from_pool(pool: Pool) -> Self
pub fn from_pool(pool: Pool) -> Self
Creates a new Postgres backend from an existing connection pool.
Useful for testing or when you want to configure the pool externally.
§Arguments
pool- A pre-configureddeadpool-postgresconnection pool.
Sourcepub async fn run_migrations(&self) -> Result<(), StorageError>
pub async fn run_migrations(&self) -> Result<(), StorageError>
Runs the schema migration to create required tables and indexes.
This is idempotent: running it multiple times has no effect if the
schema already exists (uses CREATE TABLE IF NOT EXISTS).
§Errors
Returns StorageError::Backend if the migration SQL fails to execute.
Sourcepub async fn save_edges_batch(
&self,
edges: &[DependencyEdge],
) -> Result<(), StorageError>
pub async fn save_edges_batch( &self, edges: &[DependencyEdge], ) -> Result<(), StorageError>
Saves multiple dependency edges in a single transaction.
This is more efficient than calling save_edge
individually for each edge, as it reduces round-trips to the database.
§Arguments
edges- Slice of dependency edges to persist.
§Errors
Returns StorageError::Backend if the transaction fails.
The transaction is rolled back on any error.
Trait Implementations§
Source§impl Debug for PostgresIncrementalBackend
impl Debug for PostgresIncrementalBackend
Source§impl StorageBackend for PostgresIncrementalBackend
impl StorageBackend for PostgresIncrementalBackend
Source§fn save_fingerprint<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
fingerprint: &'life2 AnalysisDefFingerprint,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save_fingerprint<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
fingerprint: &'life2 AnalysisDefFingerprint,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn load_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<AnalysisDefFingerprint>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<AnalysisDefFingerprint>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn delete_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn save_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
edge: &'life1 DependencyEdge,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
edge: &'life1 DependencyEdge,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn load_edges_from<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_edges_from<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn load_edges_to<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_edges_to<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn delete_edges_for<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_edges_for<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn load_full_graph<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DependencyGraph, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_full_graph<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<DependencyGraph, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn save_full_graph<'life0, 'life1, 'async_trait>(
&'life0 self,
graph: &'life1 DependencyGraph,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_full_graph<'life0, 'life1, 'async_trait>(
&'life0 self,
graph: &'life1 DependencyGraph,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for PostgresIncrementalBackend
impl !RefUnwindSafe for PostgresIncrementalBackend
impl Send for PostgresIncrementalBackend
impl Sync for PostgresIncrementalBackend
impl Unpin for PostgresIncrementalBackend
impl UnsafeUnpin for PostgresIncrementalBackend
impl !UnwindSafe for PostgresIncrementalBackend
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> 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