- 1
//! Standalone `__tool_worker` broker endpoint. The server process itself - 2
//! doubles as the worker in production (the `vak` binary wires the - 3
//! same subcommand); this tiny binary exists so tests can pin a REAL - 4
//! worker executable via `Core::set_tool_worker_exe` — a cargo test - 5
//! harness cannot speak the broker protocol. - 6
- 7
fn main() -> std::process::ExitCode { - 8
let invoked = std::env::args_os().nth(1); - 9
let tool_worker = - 10
invoked.as_deref() == Some(std::ffi::OsStr::new(vak_tools::broker::WORKER_SUBCOMMAND)); - 11
let persistent_worker = invoked.as_deref() - 12
== Some(std::ffi::OsStr::new( - 13
vak_tools::broker::PERSISTENT_WORKER_SUBCOMMAND, - 14
)); - 15
if !tool_worker && !persistent_worker { - 16
eprintln!("internal tool worker; do not invoke directly"); - 17
return std::process::ExitCode::from(64); - 18
} - 19
let code = match tokio::runtime::Builder::new_current_thread() - 20
.enable_all() - 21
.build() - 22
{ - 23
Ok(runtime) if persistent_worker => { - 24
runtime.block_on(vak_tools::broker::persistent_worker_main()) - 25
} - 26
Ok(runtime) => runtime.block_on(vak_tools::broker::worker_main()), - 27
Err(_) => 125, - 28
}; - 29
std::process::ExitCode::from(u8::try_from(code).unwrap_or(125)) - 30
} - 31
source · Rust
Vak Tool Worker
crates/vak-server/src/bin/vak-tool-worker.rs1.2 KB31 linesSnapshot ed4ab258