mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 18:02:56 +00:00
This upgrades the `proxy/` crate as well as the forked libraries in `libs/proxy/` to edition 2024. Also reformats the imports of those forked libraries via: ``` cargo +nightly fmt -p proxy -p postgres-protocol2 -p postgres-types2 -p tokio-postgres2 -- -l --config imports_granularity=Module,group_imports=StdExternalCrate,reorder_imports=true ``` It can be read commit-by-commit: the first commit has no formatting changes, only changes to accomodate the new edition. Part of #10918
31 lines
764 B
Rust
31 lines
764 B
Rust
use bytes::BytesMut;
|
|
use postgres_protocol2::message::frontend;
|
|
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
|
|
|
|
use crate::config::SslMode;
|
|
use crate::tls::TlsConnect;
|
|
use crate::{Error, connect_tls};
|
|
|
|
pub async fn cancel_query_raw<S, T>(
|
|
stream: S,
|
|
mode: SslMode,
|
|
tls: T,
|
|
process_id: i32,
|
|
secret_key: i32,
|
|
) -> Result<(), Error>
|
|
where
|
|
S: AsyncRead + AsyncWrite + Unpin,
|
|
T: TlsConnect<S>,
|
|
{
|
|
let mut stream = connect_tls::connect_tls(stream, mode, tls).await?;
|
|
|
|
let mut buf = BytesMut::new();
|
|
frontend::cancel_request(process_id, secret_key, &mut buf);
|
|
|
|
stream.write_all(&buf).await.map_err(Error::io)?;
|
|
stream.flush().await.map_err(Error::io)?;
|
|
stream.shutdown().await.map_err(Error::io)?;
|
|
|
|
Ok(())
|
|
}
|