mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 13:02:55 +00:00
Rework walkeeper protocol to use libpq (#366)
Most of the work here was done on the postgres side. There's more
information in the commit message there.
(see: 04cfa326a5)
On the WAL acceptor side, we're now expecting 'START_WAL_PUSH' to
initialize the WAL keeper protocol. Everything else is mostly the same,
with the only real difference being that protocol messages are now
discrete CopyData messages sent over the postgres protocol.
For the sake of documentation, the full set of these messages is:
<- recv: START_WAL_PUSH query
<- recv: server info from postgres (type `ServerInfo`)
-> send: walkeeper info (type `SafeKeeperInfo`)
<- recv: vote info (type `RequestVote`)
if node id mismatch:
-> send: self node id (type `NodeId`); exit
-> send: confirm vote (with node id) (type `NodeId`)
loop:
<- recv: info and maybe WAL block (type `SafeKeeperRequest` + bytes)
(break loop if done)
-> send: confirm receipt (type `SafeKeeperResponse`)
This commit is contained in:
@@ -10,7 +10,7 @@ use log::*;
|
||||
use rand::Rng;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::{self, BufReader, Write};
|
||||
use std::net::{Shutdown, TcpStream};
|
||||
use std::net::{Shutdown, SocketAddr, TcpStream};
|
||||
use std::str::FromStr;
|
||||
|
||||
pub trait Handler {
|
||||
@@ -137,6 +137,10 @@ impl PostgresBackend {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_peer_addr(&self) -> Result<SocketAddr> {
|
||||
Ok(self.stream_out.peer_addr()?)
|
||||
}
|
||||
|
||||
pub fn take_stream_in(&mut self) -> Option<BufReader<TcpStream>> {
|
||||
self.stream_in.take()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user