pub struct RunnerRouter { /* private fields */ }Expand description
Router that selects an appropriate Runner for a given TaskSpec.
Runners are checked in the order they were registered.
The first runner whose Runner::supports method returns true and satisfies
the TaskSpec::runner_selector (if any) is used to build the task.
§Notes
TaskKind::Embeddedis not routable — useSupervisorApi::submit_with_taskinstead.- Default
BuildContextuses empty env andNoOpMetrics.
§Also
Runner— trait that concrete executors implement.BuildContext— shared dependencies for all runners.RunnerError::NoRunner— returned when no runner matches.
Implementations§
Source§impl RunnerRouter
impl RunnerRouter
Sourcepub fn with_context(self, ctx: BuildContext) -> Self
pub fn with_context(self, ctx: BuildContext) -> Self
Set a custom build context for all runners managed by this router.
This is typically used to inject shared dependencies (config, observability, global handles, etc.) into runner instances.
Sourcepub fn register(&mut self, runner: Arc<dyn Runner>)
pub fn register(&mut self, runner: Arc<dyn Runner>)
Register a new runner without labels.
Runners are queried in the order they are registered; the first one that reports supports(spec) == true (and matches labels, if any) is used.
Sourcepub fn register_with_labels(&mut self, runner: Arc<dyn Runner>, labels: Labels)
pub fn register_with_labels(&mut self, runner: Arc<dyn Runner>, labels: Labels)
Register a new runner with static labels.
These labels are used by the router to further narrow down candidates when TaskSpec::runner_selector is set.
Sourcepub fn pick(&self, spec: &TaskSpec) -> Option<&Arc<dyn Runner>>
pub fn pick(&self, spec: &TaskSpec) -> Option<&Arc<dyn Runner>>
Pick the first runner that claims to support the given spec and matches the runner selector.
Routing rules:
- filter runners by
Runner::supports(spec); - if
spec.runner_selector()is set, keep only runners whoselabelssatisfy allmatch_labelsandmatch_expressionsrequirements; - pick the first matching entry.
Sourcepub fn build(&self, spec: &TaskSpec) -> Result<TaskRef, RunnerError>
pub fn build(&self, spec: &TaskSpec) -> Result<TaskRef, RunnerError>
Build a TaskRef for the given spec using the selected runner.
TaskKind::Embedded is not routable and must be used with
SupervisorApi::submit_with_task.
Sourcepub fn contains_label(&self, label_key: &str, label_value: &str) -> bool
pub fn contains_label(&self, label_key: &str, label_value: &str) -> bool
Returns true if at least one registered runner has label_key == label_value.