mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-17 21:20:37 +00:00
## Problem PGLB/Neonkeeper needs to separate the concerns of connecting to compute, and authenticating to compute. Additionally, the code within `connect_to_compute` is rather messy, spending effort on recovering the authentication info after wake_compute. ## Summary of changes Split `ConnCfg` into `ConnectInfo` and `AuthInfo`. `wake_compute` only returns `ConnectInfo` and `AuthInfo` is determined separately from the `handshake`/`authenticate` process. Additionally, `ConnectInfo::connect_raw` is in-charge or establishing the TLS connection, and the `postgres_client::Config::connect_raw` is configured to use `NoTls` which will force it to skip the TLS negotiation. This should just work.
47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
use std::io;
|
|
|
|
use tokio::net::TcpStream;
|
|
|
|
use crate::client::SocketConfig;
|
|
use crate::config::{Host, SslMode};
|
|
use crate::tls::MakeTlsConnect;
|
|
use crate::{Error, cancel_query_raw, connect_socket};
|
|
|
|
pub(crate) async fn cancel_query<T>(
|
|
config: Option<SocketConfig>,
|
|
ssl_mode: SslMode,
|
|
tls: T,
|
|
process_id: i32,
|
|
secret_key: i32,
|
|
) -> Result<(), Error>
|
|
where
|
|
T: MakeTlsConnect<TcpStream>,
|
|
{
|
|
let config = match config {
|
|
Some(config) => config,
|
|
None => {
|
|
return Err(Error::connect(io::Error::new(
|
|
io::ErrorKind::InvalidInput,
|
|
"unknown host",
|
|
)));
|
|
}
|
|
};
|
|
|
|
let hostname = match &config.host {
|
|
Host::Tcp(host) => &**host,
|
|
};
|
|
let tls = tls
|
|
.make_tls_connect(hostname)
|
|
.map_err(|e| Error::tls(e.into()))?;
|
|
|
|
let socket = connect_socket::connect_socket(
|
|
config.host_addr,
|
|
&config.host,
|
|
config.port,
|
|
config.connect_timeout,
|
|
)
|
|
.await?;
|
|
|
|
cancel_query_raw::cancel_query_raw(socket, ssl_mode, tls, process_id, secret_key).await
|
|
}
|