mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-30 03:20:36 +00:00
pageserver stub
This commit is contained in:
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
use postgres_protocol::message::backend::ReplicationMessage;
|
||||
use tokio_stream::StreamExt;
|
||||
use tokio_postgres::{connect_replication, Error, NoTls, ReplicationMode};
|
||||
|
||||
#[tokio::main] // By default, tokio_postgres uses the tokio crate as its runtime.
|
||||
async fn main() -> Result<(), Error> {
|
||||
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(())
|
||||
}
|
||||
Reference in New Issue
Block a user