Connect to a migration endpoint and return the established stream.
(
destination_url: &str,
)
| 786 | |
| 787 | /// Connect to a migration endpoint and return the established stream. |
| 788 | pub(crate) fn send_migration_socket( |
| 789 | destination_url: &str, |
| 790 | ) -> Result<SocketStream, MigratableError> { |
| 791 | if let Some(address) = destination_url.strip_prefix("tcp:") { |
| 792 | info!("Connecting to TCP socket at {address}"); |
| 793 | |
| 794 | let socket = TcpStream::connect(address).map_err(|e| { |
| 795 | MigratableError::MigrateSend(anyhow!("Error connecting to TCP socket: {e}")) |
| 796 | })?; |
| 797 | |
| 798 | Ok(SocketStream::Tcp(socket)) |
| 799 | } else { |
| 800 | let path = socket_url_to_path(destination_url).map_err(MigratableError::MigrateSend)?; |
| 801 | info!("Connecting to UNIX socket at {path:?}"); |
| 802 | |
| 803 | let socket = UnixStream::connect(&path).map_err(|e| { |
| 804 | MigratableError::MigrateSend(anyhow!("Error connecting to UNIX socket: {e}")) |
| 805 | })?; |
| 806 | |
| 807 | Ok(SocketStream::Unix(socket)) |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /// Bind a migration listener for the receiver side. |
| 812 | pub(crate) fn receive_migration_listener( |
no test coverage detected