Change name of functions responsible for router handling
run_router changed to run_router_spawner, because it spawns the router task
get_worker_handle changed to run_router and moved closer to run_router_spawner
@@ -117,8 +117,7 @@ impl Connection {
let (error_sender, error_receiver) = tokio::sync::oneshot::channel();
- let _worker_handle =
- Self::get_worker_handle(&config, stream, receiver, error_sender).await?;
+ let _worker_handle = Self::run_router(&config, stream, receiver, error_sender).await?;
let connection = Connection {
submit_channel: sender,
@@ -133,36 +132,6 @@ impl Connection {
Ok((connection, error_receiver))
}
- #[cfg(feature = "ssl")]
- async fn get_worker_handle(
- config: &ConnectionConfig,
- stream: TcpStream,
- receiver: mpsc::Receiver<Task>,
- error_sender: tokio::sync::oneshot::Sender<QueryError>,
- ) -> Result<RemoteHandle<()>, std::io::Error> {
- let res = match config.ssl_context {
- Some(ref context) => {
- let ssl = Ssl::new(context)?;
- let mut stream = SslStream::new(ssl, stream)?;
- let _pin = Pin::new(&mut stream).connect().await;
- Self::run_router(stream, receiver, error_sender)
- }
- None => Self::run_router(stream, receiver, error_sender),
- };
- Ok(res)
- }
-
- #[cfg(not(feature = "ssl"))]
- async fn get_worker_handle(
- config: &ConnectionConfig,
- stream: TcpStream,
- receiver: mpsc::Receiver<Task>,
- error_sender: tokio::sync::oneshot::Sender<QueryError>,
- ) -> Result<RemoteHandle<()>, std::io::Error> {
- let _config = config;
- Ok(Self::run_router(stream, receiver, error_sender))
- }
-
pub async fn startup(&self, options: HashMap<String, String>) -> Result<Response, QueryError> {
self.send_request(&request::Startup { options }, false)
.await
@@ -415,7 +384,37 @@ impl Connection {
Ok(response)
}
- fn run_router(
+ #[cfg(feature = "ssl")]
+ async fn run_router(
+ config: &ConnectionConfig,
+ stream: TcpStream,
+ receiver: mpsc::Receiver<Task>,
+ error_sender: tokio::sync::oneshot::Sender<QueryError>,
+ ) -> Result<RemoteHandle<()>, std::io::Error> {
+ let res = match config.ssl_context {
+ Some(ref context) => {
+ let ssl = Ssl::new(context)?;
+ let mut stream = SslStream::new(ssl, stream)?;
+ let _pin = Pin::new(&mut stream).connect().await;
+ Self::run_router_spawner(stream, receiver, error_sender)
+ }
+ None => Self::run_router_spawner(stream, receiver, error_sender),
+ };
+ Ok(res)
+ }
+
+ #[cfg(not(feature = "ssl"))]
+ async fn run_router(
+ config: &ConnectionConfig,
+ stream: TcpStream,
+ receiver: mpsc::Receiver<Task>,
+ error_sender: tokio::sync::oneshot::Sender<QueryError>,
+ ) -> Result<RemoteHandle<()>, std::io::Error> {
+ let _config = config;
+ Ok(Self::run_router_spawner(stream, receiver, error_sender))
+ }
+
+ fn run_router_spawner(
stream: (impl AsyncRead + AsyncWrite + Send + 'static),
receiver: mpsc::Receiver<Task>,
error_sender: tokio::sync::oneshot::Sender<QueryError>,
