(
addr: SocketAddr,
options: &PgDumpOptions,
networking: N,
)
| 186 | } |
| 187 | |
| 188 | fn dump_sql_with_networking<N>( |
| 189 | addr: SocketAddr, |
| 190 | options: &PgDumpOptions, |
| 191 | networking: N, |
| 192 | ) -> Result<String> |
| 193 | where |
| 194 | N: VirtualNetworking + Sync, |
| 195 | { |
| 196 | options.validate()?; |
| 197 | let _phase = timing::phase("pg_dump"); |
| 198 | let wasm = { |
| 199 | let _phase = timing::phase("pg_dump.load_embedded_module"); |
| 200 | assets::pg_dump_wasm() |
| 201 | .ok_or_else(|| anyhow!("WASIX pg_dump asset is not bundled in this build"))? |
| 202 | }; |
| 203 | let engine = aot::headless_engine(); |
| 204 | let module = { |
| 205 | let _phase = timing::phase("pg_dump.load_aot"); |
| 206 | aot::load_pg_dump_module(&engine)? |
| 207 | }; |
| 208 | let _store = Store::new(engine.clone()); |
| 209 | |
| 210 | let fs_root = TempDir::new().context("create pg_dump WASIX filesystem root")?; |
| 211 | let runtime = { |
| 212 | let _phase = timing::phase("pg_dump.tokio_runtime"); |
| 213 | tokio::runtime::Builder::new_multi_thread() |
| 214 | .enable_all() |
| 215 | .build() |
| 216 | .context("create Tokio runtime for WASIX pg_dump")? |
| 217 | }; |
| 218 | let (host_fs, wasix_runtime) = { |
| 219 | let _phase = timing::phase("pg_dump.wasix_runtime"); |
| 220 | let _runtime_guard = runtime.enter(); |
| 221 | let host_fs = SyncHostFileSystem::new(fs_root.path()).with_context(|| { |
| 222 | format!( |
| 223 | "create host filesystem rooted at {}", |
| 224 | fs_root.path().display() |
| 225 | ) |
| 226 | })?; |
| 227 | let host_fs = Arc::new(host_fs) as Arc<dyn virtual_fs::FileSystem + Send + Sync>; |
| 228 | let mut wasix_runtime = PluggableRuntime::new(Arc::new(TokioTaskManager::new( |
| 229 | tokio::runtime::Handle::current(), |
| 230 | ))); |
| 231 | wasix_runtime.set_engine(engine.clone()); |
| 232 | wasix_runtime.set_networking_implementation(networking); |
| 233 | (host_fs, wasix_runtime) |
| 234 | }; |
| 235 | |
| 236 | let output_path = "/host/out.sql"; |
| 237 | let port = addr.port().to_string(); |
| 238 | let host = match addr { |
| 239 | SocketAddr::V4(addr) => addr.ip().to_string(), |
| 240 | SocketAddr::V6(addr) => addr.ip().to_string(), |
| 241 | }; |
| 242 | let mut args = options.args.clone(); |
| 243 | args.extend([ |
| 244 | "-U".to_owned(), |
| 245 | options.username.clone(), |
no test coverage detected