Skip to main content

Crate solti_runner

Crate solti_runner 

Source
Expand description

§solti-runner

Runner plugin interface, routing, and execution metrics for the solti task system.

This crate defines how task executors (runners) are declared, selected, and observed. It sits between the domain model (solti_model) and the orchestration layer (solti-core), providing a stable plugin boundary.

§Architecture

 TaskSpec ──► RunnerRouter ──► Runner::build_task() ──► TaskRef
                 │                    ▲
                 │  label matching    │  BuildContext
                 │  + supports()      │  (env + metrics)
                 ▼                    │
             RunnerEntry          MetricsHandle
             (runner + labels)    (Arc<dyn MetricsBackend>)

§Public API

ItemDescription
RunnerTrait that concrete executors implement
RunnerRouterSelects a runner for a given TaskSpec by supports() + label matching
BuildContextShared dependencies injected into runners (env + metrics)
RunIdHuman-readable run identifier ({runner}-{slot}-{seq})
RunnerErrorError type for runner operations
MetricsBackendTrait for collecting task execution metrics
MetricsHandleArc<dyn MetricsBackend> — cloneable shared handle
NoOpMetricsZero-size backend that compiles to nothing
RunnerTypeMetric label: Subprocess, Wasm, Container
TaskOutcomeMetric label: Success, Failure, Canceled, Timeout

§Runner implementation

A runner must implement Runner and be registered in a RunnerRouter:

use solti_runner::{Runner, RunnerError, BuildContext, RunId};
use solti_model::TaskSpec;
use taskvisor::TaskRef;

struct MyRunner;

impl Runner for MyRunner {
    fn name(&self) -> &'static str { "my-runner" }

    fn supports(&self, spec: &TaskSpec) -> bool {
        matches!(spec.kind(), solti_model::TaskKind::Subprocess(_))
    }

    fn build_task(&self, spec: &TaskSpec, ctx: &BuildContext) -> Result<TaskRef, RunnerError> {
        // build and return a TaskRef
        todo!()
    }
}

§Routing

RunnerRouter selects the first registered runner that:

  1. returns true from Runner::supports for the given spec, and
  2. satisfies the RunnerSelector label constraints (if any).
use solti_runner::{RunnerRouter, BuildContext};

let mut router = RunnerRouter::new();
router.register(Arc::new(MyRunner));

let task_ref = router.build(&spec)?;

§Metrics

Metrics are collected via MetricsBackend, injected through BuildContext. The default is NoOpMetrics (zero-cost). Backends like solti-prometheus implement MetricsBackend for production use.

§Also

Re-exports§

pub use metrics::MetricsBackend;
pub use metrics::MetricsHandle;
pub use metrics::NoOpMetrics;
pub use metrics::RunnerType;
pub use metrics::TaskOutcome;
pub use metrics::noop_metrics;

Modules§

metrics
Metrics collection abstraction.

Structs§

BuildContext
Shared build context passed to all runners.
RunId
Result of make_run_id: a human-readable run id and the raw sequence number.
RunnerRouter
Router that selects an appropriate Runner for a given TaskSpec.

Enums§

RunnerError
Errors produced by runner operations.

Traits§

Runner
Generic task runner used by the core layer.

Functions§

make_run_id
Build a human-readable run id used as task name for taskvisor.