pub struct PgDocumentBuilder { /* private fields */ }Expand description
Builds index documents from a Postgres database, driven by a SourceSpec —
the enabled indexes and their schemas, translated from the top-level config
by the composition root. Cheap to clone — the pool, spec, and primary-key
cache are shared.
Implementations§
Source§impl PgDocumentBuilder
impl PgDocumentBuilder
pub fn new(pool: PgPool, spec: Arc<SourceSpec>) -> Self
pub async fn connect( connection_url: &str, spec: Arc<SourceSpec>, ) -> Result<Self>
Sourcepub async fn sample_document(
&self,
index: &IndexName,
) -> Result<Option<GenericValue>>
pub async fn sample_document( &self, index: &IndexName, ) -> Result<Option<GenericValue>>
Build a real document for one arbitrary row of an index’s root table —
exactly what the sink would write, for previewing a schema against live
data. Picks any row with a non-null primary key, then runs it through the
normal build path. Returns Ok(None) when the
index has no single-column primary key or its root table is empty.
Trait Implementations§
Source§impl Catalog for PgDocumentBuilder
The Postgres source’s view of its own catalog. The index mapping is derived
from the self-describing schema in schema_core; this is the one
store-specific piece used for validation — how Postgres types and
constrains a column — so a declared schema can be checked against the live
database.
impl Catalog for PgDocumentBuilder
The Postgres source’s view of its own catalog. The index mapping is derived
from the self-describing schema in schema_core; this is the one
store-specific piece used for validation — how Postgres types and
constrains a column — so a declared schema can be checked against the live
database.
Source§fn column<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
schema: &'life1 DatabaseSchema,
table: &'life2 TableName,
column: &'life3 ColumnName,
) -> Pin<Box<dyn Future<Output = Result<ColumnInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn column<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
schema: &'life1 DatabaseSchema,
table: &'life2 TableName,
column: &'life3 ColumnName,
) -> Pin<Box<dyn Future<Output = Result<ColumnInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
column in table (within schema), as the
store defines it.Source§impl Clone for PgDocumentBuilder
impl Clone for PgDocumentBuilder
Source§fn clone(&self) -> PgDocumentBuilder
fn clone(&self) -> PgDocumentBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PgDocumentBuilder
impl Debug for PgDocumentBuilder
Source§impl DocumentBuilder for PgDocumentBuilder
impl DocumentBuilder for PgDocumentBuilder
Source§fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 TableName,
key: &'life2 RowKey,
) -> Pin<Box<dyn Future<Output = Result<Vec<DocumentId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 TableName,
key: &'life2 RowKey,
) -> Pin<Box<dyn Future<Output = Result<Vec<DocumentId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<Document>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 DocumentId,
) -> Pin<Box<dyn Future<Output = Result<Document>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn build_many<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [DocumentId],
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn build_many<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [DocumentId],
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Document per requested
id — an Upsert, or a Delete tombstone when the root row is absent —
in any order; callers match results back by Document::id. Read moreSource§fn backfill_scopes(&self) -> Vec<IndexScope>
fn backfill_scopes(&self) -> Vec<IndexScope>
Source§fn index_mappings<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<IndexMapping>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn index_mappings<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<IndexMapping>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
mapping where one is given, and from
the source’s own column types otherwise. Sinks that own their index use
this to create it up front. The default is empty — a builder that leaves
index creation to whatever the sink does on first write.Auto Trait Implementations§
impl !RefUnwindSafe for PgDocumentBuilder
impl !UnwindSafe for PgDocumentBuilder
impl Freeze for PgDocumentBuilder
impl Send for PgDocumentBuilder
impl Sync for PgDocumentBuilder
impl Unpin for PgDocumentBuilder
impl UnsafeUnpin for PgDocumentBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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