Remove leftover duplicated code to start replication connection

This commit is contained in:
Heikki Linnakangas
2021-03-16 11:26:48 +02:00
committed by Stas Kelvich
parent 9a9480e8c9
commit eac04d7f10

View File

@@ -4,6 +4,8 @@ mod page_cache;
mod walreader;
mod walreceiver;
use std::io::Error;
fn main() -> Result<(), Error> {
@@ -17,31 +19,5 @@ fn main() -> Result<(), Error> {
handler.join(); // never returns.
let conninfo = "host=localhost port=65432 user=stas dbname=postgres";
// form replication connection
let (mut rclient, rconnection) =
connect_replication(conninfo, NoTls, ReplicationMode::Physical).await?;
tokio::spawn(async move {
if let Err(e) = rconnection.await {
eprintln!("connection error: {}", e);
}
});
let identify_system = rclient.identify_system().await?;
let mut physical_stream = rclient
.start_physical_replication(None, identify_system.xlogpos(), None)
.await?;
while let Some(replication_message) = physical_stream.next().await {
match replication_message? {
ReplicationMessage::XLogData(xlog_data) => {
// eprintln!("received XLogData: {:#?}", xlog_data);
eprintln!("received XLogData:");
}
ReplicationMessage::PrimaryKeepAlive(keepalive) => {
// eprintln!("received PrimaryKeepAlive: {:#?}", keepalive);
eprintln!("received PrimaryKeepAlive:");
}
_ => (),
}
}
Ok(())
}