pub struct CdcApp { /* private fields */ }Expand description
High-level CDC application runner
This struct encapsulates the complete CDC application workflow, providing a clean interface for running CDC replication with proper initialization, shutdown handling, and error management.
Implementations§
Source§impl CdcApp
impl CdcApp
Sourcepub async fn new(config: CdcAppConfig) -> CdcResult<Self>
pub async fn new(config: CdcAppConfig) -> CdcResult<Self>
Sourcepub async fn from_config(cdc_config: Config) -> CdcResult<Self>
pub async fn from_config(cdc_config: Config) -> CdcResult<Self>
Sourcepub async fn run(&mut self, lsn_file_path: Option<&str>) -> CdcResult<()>
pub async fn run(&mut self, lsn_file_path: Option<&str>) -> CdcResult<()>
Run the CDC application with graceful shutdown handling
This method starts the CDC replication process and handles graceful shutdown when shutdown signals are received. It automatically loads the last LSN from persistence to resume replication from where it left off.
This method now automatically handles metrics server initialization when the metrics feature is enabled, removing the need for feature checking in the main application.
§Arguments
lsn_file_path- Optional path to the LSN persistence file. If None, uses the default from environment variables or “./pg2any_last_lsn”
§Returns
Returns CdcResult<()> when the application completes successfully
or is gracefully shut down.
§Errors
Returns CdcError if:
- Replication fails to start or encounters an error
- Shutdown handling fails
- Client stop operation fails
- Metrics server fails to start (when metrics feature is enabled)
Auto Trait Implementations§
impl Freeze for CdcApp
impl !RefUnwindSafe for CdcApp
impl Send for CdcApp
impl Sync for CdcApp
impl Unpin for CdcApp
impl !UnwindSafe for CdcApp
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