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
| Item | Description |
|---|---|
Runner | Trait that concrete executors implement |
RunnerRouter | Selects a runner for a given TaskSpec by supports() + label matching |
BuildContext | Shared dependencies injected into runners (env + metrics) |
RunId | Human-readable run identifier ({runner}-{slot}-{seq}) |
RunnerError | Error type for runner operations |
MetricsBackend | Trait for collecting task execution metrics |
MetricsHandle | Arc<dyn MetricsBackend> — cloneable shared handle |
NoOpMetrics | Zero-size backend that compiles to nothing |
RunnerType | Metric label: Subprocess, Wasm, Container |
TaskOutcome | Metric 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:
- returns
truefromRunner::supportsfor the given spec, and - satisfies the
RunnerSelectorlabel 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
solti_model— domain types consumed by runners (TaskSpec,TaskKind).taskvisor::TaskRef— the concrete task handle returned byRunner::build_task.solti-exec— subprocess runner implementation.solti-prometheus— PrometheusMetricsBackendimplementation.
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§
- Build
Context - Shared build context passed to all runners.
- RunId
- Result of
make_run_id: a human-readable run id and the raw sequence number. - Runner
Router - Router that selects an appropriate
Runnerfor a givenTaskSpec.
Enums§
- Runner
Error - 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.