Skip to main content

RunnerRouter

Struct RunnerRouter 

Source
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::Embedded is not routable — use SupervisorApi::submit_with_task instead.
  • Default BuildContext uses empty env and NoOpMetrics.

§Also

Implementations§

Source§

impl RunnerRouter

Source

pub fn new() -> Self

Create an empty router with a default build context.

Source

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.

Source

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.

Source

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.

Source

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 whose labels satisfy all match_labels and match_expressions requirements;
  • pick the first matching entry.
Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for RunnerRouter

Source§

fn default() -> RunnerRouter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more