pub async fn run_oop_with_options(opts: OopRunOptions) -> Result<()>Expand description
Run an out-of-process gear with the given options
This function:
- Creates a root
CancellationTokenfor the process - Hooks OS signals (SIGTERM, SIGINT, Ctrl+C) to trigger cancellation
- Loads configuration and initializes logging
- Connects to the
DirectoryService - Registers the gear instance
- Starts a background heartbeat loop (using a child token)
- Runs the gear lifecycle with
ShutdownOptions::Token - Deregisters from
DirectoryServiceon shutdown
§Shutdown Model
A single root cancellation token drives shutdown for the entire process.
OS signals are hooked at this bootstrap level (not via ShutdownOptions::Signals).
The heartbeat loop and gear runtime both observe this token tree.
§Arguments
opts- Bootstrap configuration options
§Returns
Ok(())- If the gear lifecycle completed successfullyErr(e)- If any step failed
§Example
use toolkit::bootstrap::oop::{OopRunOptions, run_oop_with_options};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opts = OopRunOptions {
gear_name: "file-parser".to_string(),
instance_id: None,
directory_endpoint: "http://127.0.0.1:50051".to_string(),
config_path: None,
verbose: 1,
print_config: false,
heartbeat_interval_secs: 5,
};
run_oop_with_options(opts).await
}§Errors
Returns an error if the OoP gear fails to start or run.