Skip to main content

Module oop

Module oop 

Source
Expand description

Out-of-process gear bootstrap library

This gear provides reusable functionality for bootstrapping OoP (out-of-process) ToolKit gears in local (non-k8s) environments.

§Features

  • Configuration loading using toolkit-bootstrap
  • Logging initialization with tracing
  • gRPC connection to DirectoryService
  • Gear instance registration
  • Heartbeat management
  • Gear lifecycle execution

§Shutdown Model

Shutdown is driven by a single root CancellationToken per process:

  • OS signals (SIGTERM, SIGINT, Ctrl+C) are hooked at bootstrap level
  • The root token is passed to RunOptions::Token for gear runtime shutdown
  • Background tasks (like heartbeat) use child tokens derived from the root

On shutdown, the gear deregisters itself from the DirectoryService before exiting.

§Example

use toolkit::bootstrap::oop::{OopRunOptions, run_oop_with_options};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let opts = OopRunOptions {
        gear_name: "my_gear".to_string(),
        instance_id: None,
        directory_endpoint: "http://127.0.0.1:50051".to_string(),
        config_path: None,
        verbose: 0,
        print_config: false,
        heartbeat_interval_secs: 5,
    };

    run_oop_with_options(opts).await
}

Structs§

OopRunOptions
Configuration options for OoP gear bootstrap

Functions§

run_oop_with_options
Run an out-of-process gear with the given options