pub struct WalChangeCapture { /* private fields */ }Expand description
Postgres change capture over logical replication (pgoutput).
Exposes the two ChangeCapture capabilities the engine orchestrates:
liveconnects to a replication slot and streams committed row changes as thinChanges. Resume is the slot’s: itsconfirmed_flush_lsnis the durable cursor on the server, advanced as the engine confirms changes (seeAck).snapshotreads current rows over an ordinary SQL connection for an initial backfill (see the crate-privatebackfill). The engine calls it only for tables backing an index the sink reports as unseeded.
§Prerequisites
The server must have wal_level = logical. The replication slot is
created automatically on first connect if it does not exist yet, and the
publication is created/extended to cover every table any index reads —
see CaptureProvisioning — when the role is privileged enough and
management is not opted out; otherwise flusso warns with the SQL to run.
Implementations§
Source§impl WalChangeCapture
impl WalChangeCapture
Sourcepub fn new(config: ReplicationConfig, connection_url: impl Into<String>) -> Self
pub fn new(config: ReplicationConfig, connection_url: impl Into<String>) -> Self
Create a capture from a pgwire-replication configuration and the
ordinary SQL connection URL the snapshot reads through (the same URL the
document builder connects with).
Leave config.start_lsn at Lsn::ZERO
to resume from the slot’s confirmed_flush_lsn — the usual choice.
Sourcepub fn with_publication_management(
self,
required: BTreeSet<QualifiedTable>,
manage: bool,
) -> Self
pub fn with_publication_management( self, required: BTreeSet<QualifiedTable>, manage: bool, ) -> Self
Declare the tables the publication must cover and whether to provision
the gap automatically on live. required is typically
SourceSpec::all_tables; the
composition root supplies it along with the manage opt-out.
Trait Implementations§
Source§impl CaptureProvisioning for WalChangeCapture
impl CaptureProvisioning for WalChangeCapture
Source§fn inspect_coverage<'life0, 'life1, 'async_trait>(
&'life0 self,
required: &'life1 BTreeSet<QualifiedTable>,
) -> Pin<Box<dyn Future<Output = Result<CoverageReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn inspect_coverage<'life0, 'life1, 'async_trait>(
&'life0 self,
required: &'life1 BTreeSet<QualifiedTable>,
) -> Pin<Box<dyn Future<Output = Result<CoverageReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
required against what the source streams,
and whether the gap (if any) is manageable. Never mutates anything.Source§fn ensure_coverage<'life0, 'life1, 'async_trait>(
&'life0 self,
required: &'life1 BTreeSet<QualifiedTable>,
manage: bool,
) -> Pin<Box<dyn Future<Output = Result<CoverageReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ensure_coverage<'life0, 'life1, 'async_trait>(
&'life0 self,
required: &'life1 BTreeSet<QualifiedTable>,
manage: bool,
) -> Pin<Box<dyn Future<Output = Result<CoverageReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
manage is set and the gap is
manageable; otherwise a no-op. Returns the report as observed before
acting (so a caller can log what was — or would have been — done). A
no-op for an already-satisfied set.Source§impl ChangeCapture for WalChangeCapture
impl ChangeCapture for WalChangeCapture
Source§fn lag<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn lag<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Bytes between the slot’s confirmed_flush_lsn and the server’s current
WAL LSN — how far behind the destination is. Returns None until the
slot exists (it is created on the first live connect).
Source§fn live<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<Change>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn live<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<Change>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl Clone for WalChangeCapture
impl Clone for WalChangeCapture
Source§fn clone(&self) -> WalChangeCapture
fn clone(&self) -> WalChangeCapture
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WalChangeCapture
impl !UnwindSafe for WalChangeCapture
impl Freeze for WalChangeCapture
impl Send for WalChangeCapture
impl Sync for WalChangeCapture
impl Unpin for WalChangeCapture
impl UnsafeUnpin for WalChangeCapture
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