pub struct PostgresStorage { /* private fields */ }Expand description
PostgreSQL storage backend for JACS documents.
Implements StorageDocumentTraits, DatabaseDocumentTraits, and
SearchProvider. Supports fulltext search via PostgreSQL tsvector.
Vector search (pgvector) is not yet implemented but the capability
reporting is prepared for it.
Implementations§
Source§impl PostgresStorage
impl PostgresStorage
Sourcepub fn new(
database_url: &str,
max_connections: Option<u32>,
min_connections: Option<u32>,
connect_timeout_secs: Option<u64>,
) -> Result<Self, JacsError>
pub fn new( database_url: &str, max_connections: Option<u32>, min_connections: Option<u32>, connect_timeout_secs: Option<u64>, ) -> Result<Self, JacsError>
Create a new PostgresStorage connected to the given PostgreSQL URL.
Pool settings:
max_connections: Maximum pool size (default 10)min_connections: Minimum pool size (default 1)connect_timeout_secs: Connection timeout (default 30)
Trait Implementations§
Source§impl DatabaseDocumentTraits for PostgresStorage
impl DatabaseDocumentTraits for PostgresStorage
Source§fn query_by_type(
&self,
jacs_type: &str,
limit: usize,
offset: usize,
) -> Result<Vec<JACSDocument>, JacsError>
fn query_by_type( &self, jacs_type: &str, limit: usize, offset: usize, ) -> Result<Vec<JACSDocument>, JacsError>
Query documents by their
jacsType field with pagination.Source§fn query_by_field(
&self,
field_path: &str,
value: &str,
jacs_type: Option<&str>,
limit: usize,
offset: usize,
) -> Result<Vec<JACSDocument>, JacsError>
fn query_by_field( &self, field_path: &str, value: &str, jacs_type: Option<&str>, limit: usize, offset: usize, ) -> Result<Vec<JACSDocument>, JacsError>
Query documents where a JSONB field matches a value.
field_path is a top-level field name (e.g., “jacsCommitmentStatus”).Source§fn get_versions(&self, jacs_id: &str) -> Result<Vec<JACSDocument>, JacsError>
fn get_versions(&self, jacs_id: &str) -> Result<Vec<JACSDocument>, JacsError>
Get all versions of a document ordered by creation date.
Source§fn get_latest(&self, jacs_id: &str) -> Result<JACSDocument, JacsError>
fn get_latest(&self, jacs_id: &str) -> Result<JACSDocument, JacsError>
Get the most recent version of a document.
Source§impl SearchProvider for PostgresStorage
impl SearchProvider for PostgresStorage
Source§fn search(&self, query: SearchQuery) -> Result<SearchResults, JacsError>
fn search(&self, query: SearchQuery) -> Result<SearchResults, JacsError>
Search documents using the given query. Read more
Source§fn capabilities(&self) -> SearchCapabilities
fn capabilities(&self) -> SearchCapabilities
Reports what search capabilities this backend supports. Read more
Source§impl StorageDocumentTraits for PostgresStorage
impl StorageDocumentTraits for PostgresStorage
fn store_document(&self, doc: &JACSDocument) -> Result<(), JacsError>
fn get_document(&self, key: &str) -> Result<JACSDocument, JacsError>
fn remove_document(&self, key: &str) -> Result<JACSDocument, JacsError>
fn list_documents(&self, prefix: &str) -> Result<Vec<String>, JacsError>
fn document_exists(&self, key: &str) -> Result<bool, JacsError>
fn get_documents_by_agent( &self, agent_id: &str, ) -> Result<Vec<String>, JacsError>
fn get_document_versions( &self, document_id: &str, ) -> Result<Vec<String>, JacsError>
fn get_latest_document( &self, document_id: &str, ) -> Result<JACSDocument, JacsError>
fn merge_documents( &self, _doc_id: &str, _v1: &str, _v2: &str, ) -> Result<JACSDocument, JacsError>
fn store_documents( &self, docs: Vec<JACSDocument>, ) -> Result<Vec<String>, Vec<JacsError>>
fn get_documents( &self, keys: Vec<String>, ) -> Result<Vec<JACSDocument>, Vec<JacsError>>
Auto Trait Implementations§
impl Freeze for PostgresStorage
impl !RefUnwindSafe for PostgresStorage
impl Send for PostgresStorage
impl Sync for PostgresStorage
impl Unpin for PostgresStorage
impl UnsafeUnpin for PostgresStorage
impl !UnwindSafe for PostgresStorage
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 more