Skip to main content

EngineDispatcher

Struct EngineDispatcher 

Source
pub struct EngineDispatcher { /* private fields */ }
Expand description

Bridges mlua_flow_ir::AsyncDispatcher to the engine’s start_task + dispatch_attempt_with pair. Holds one Operator session token and one spawner, and spins up a fresh task per Step.ref, using it as the agent name.

Constructed via with_spawner; each dispatch goes through engine.dispatch_attempt_with(token, tid, spawner, run_id), carrying the spawner per request. Nothing is stashed on engine-global state, so multiple dispatchers can drive different Blueprints against the same Engine in parallel without racing.

Optionally carries a RunContext (via Self::with_run, issue #13 run_id propagation): when present, every dispatched step’s run_id is exposed to the worker through Ctx.meta.runtime["run_id"], and a StepEntry is appended to RunRecord.step_entries once the step’s outcome is known (dispatch is synchronous end-to-end here, so there is no need for a separate event/notification mechanism — the entry is written with its final status in one call).

Also carries the GH #21 Phase 2 named MetaDef pool (via Self::with_step_metas) — the Step tier’s dispatch-time resolver; see Self::dispatch’s doc for the full envelope contract.

GH #23: optionally carries the Blueprint’s StepNaming table (via Self::with_step_naming, built once by blueprint::compiler::Compiler::compile — see that type’s doc for the full addressing-space narrative). When present, Self::dispatch snapshots the same Arc into EngineState.step_namings for every dispatched task, keyed by its freshly-minted StepId — the storage half of the “construct once, read many” contract; Engine::step_naming_for is the read-back accessor later consumers (GH #23 subtask-2/3) pull from.

GH #27 (follow-up to #23): optionally also carries the Blueprint’s ProjectionPlacement resolver (via Self::with_projection_placement, built once by Compiler::compile) — the SAME snapshot-then-read-back contract as StepNaming above, this time read back via Engine::projection_placement_for.

Implementations§

Source§

impl EngineDispatcher

Source

pub fn with_spawner( engine: Engine, op_token: CapToken, spawner: Arc<dyn SpawnerAdapter>, ) -> Self

Build a dispatcher with no run-level tracing (run_ctx = None), no named MetaDefs (step_metas empty), and no StepNaming table — the pre-existing behavior. Use Self::with_run / Self::with_step_metas / Self::with_step_naming to opt into any of them.

Source

pub fn with_run(self, run_ctx: RunContext) -> Self

Attach a RunContext (builder style) so every dispatched step is traced into RunRecord.step_entries and exposes its run_id via Ctx.meta.runtime.

Source

pub fn with_step_metas(self, step_metas: HashMap<String, Value>) -> Self

GH #21 Phase 2: attach the named MetaDef pool (Blueprint.metas, resolved by service::task_launch::derive_step_metas into a name -> ctx map) that Self::dispatch resolves $step_meta.ref envelopes against. Unconditional to call — an empty map (the pre-#21-Phase-2 default) makes every $step_meta.ref lookup miss loudly, same as a Blueprint that never declares Blueprint.metas.

Source

pub fn with_step_naming(self, step_naming: Arc<StepNaming>) -> Self

GH #23: attach the Blueprint’s StepNaming table (built once by blueprint::compiler::Compiler::compile). None (the default via Self::with_spawner) preserves pre-GH-#23 behavior byte-for-byte — Self::dispatch simply skips the EngineState.step_namings snapshot for every caller that never opts in (e.g. tests that build an EngineDispatcher directly instead of going through service::task_launch::TaskLaunchService::launch).

Source

pub fn with_projection_placement( self, projection_placement: Arc<ProjectionPlacement>, ) -> Self

GH #27 (follow-up to #23): attach the Blueprint’s ProjectionPlacement resolver (built once by blueprint::compiler::Compiler::compile). None (the default via Self::with_spawner) preserves pre-GH-#27 behavior byte-for-byte — Self::dispatch simply skips the EngineState.projection_placements snapshot for every caller that never opts in, mirroring Self::with_step_naming’s contract.

Trait Implementations§

Source§

impl AsyncDispatcher for EngineDispatcher

Source§

fn dispatch<'life0, 'life1, 'async_trait>( &'life0 self, ref_: &'life1 str, input: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, EvalError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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