Skip to main content

ParallelWorker

Struct ParallelWorker 

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

Runs a wrapped node once per item of a list input.

Implementations§

Source§

impl ParallelWorker

Source

pub fn new( name: &str, wrapped: Arc<dyn Node>, max_concurrency: usize, cfg: NodeConfig, ) -> Result<Arc<ParallelWorker>, WorkflowError>

Wraps wrapped. The wrapped node may not carry its own RetryConfig; the worker’s own RetryConfig is taken out of cfg (hidden from the scheduler) and applied per item.

Trait Implementations§

Source§

impl Node for ParallelWorker

Source§

fn run(&self, ctx: Context, input: Value) -> EventStream

Runs the wrapped node once per list item (at most max_concurrency at a time; 0 = unlimited), each item under its own sub-branch <wrapped>@<i+1> and retried independently under the worker’s RetryConfig. The first non-retryable failure cancels the in-flight siblings and is the node’s error; otherwise one event carries the per-index outputs. Intermediate wrapped events are suppressed. Each item task runs on a fresh fiber spawned with PARALLEL_WORKER_CREATOR (its retries stay on it). Dropping the stream drops the JoinSet, aborting the workers; the engine never drops it mid-await (the scheduler drains its node tasks), so only a direct user of the stream sees the abort.

Source§

fn name(&self) -> &str

The node’s name, unique within a workflow graph.
Source§

fn description(&self) -> &str

The node’s human-readable description.
Source§

fn config(&self) -> &NodeConfig

The node’s configuration.
Source§

fn input_schema(&self) -> Option<&Value>

None = no schema, no input validation.
Source§

fn output_schema(&self) -> Option<&Value>

None = no schema, no output validation.
Source§

fn validate_input(&self, v: Value) -> Result<Value, WorkflowError>

Called by the scheduler before run on every activation.
Source§

fn validate_output(&self, v: Value) -> Result<Value, WorkflowError>

Called by the scheduler on every yielded event with an output.
Source§

fn as_any(&self) -> &dyn Any

Downcasting support, to tell concrete node types apart.
Source§

fn state_field_names(&self) -> Option<&[String]>

The names of the state fields the node binds as parameters; None = node does not bind state params.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ParallelWorker

§

impl !UnwindSafe for ParallelWorker

§

impl Forget for ParallelWorker

§

impl Freeze for ParallelWorker
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn Fn(&AgentError) -> bool + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&AgentError) -> bool + Sync + Send>>: Freeze, *const ArcInner<CompiledSchema> is !null: Freeze, PhantomData<ArcInner<CompiledSchema>>: Freeze, *const ArcInner<dyn Node> is !null: Freeze, PhantomData<ArcInner<dyn Node>>: Freeze,

§

impl Move for ParallelWorker

§

impl Send for ParallelWorker
where RawVecInner: Send, Arc<dyn Fn(&AgentError) -> bool + Sync + Send>: Send, Arc<CompiledSchema>: Send, Arc<dyn Node>: Send,

§

impl Sync for ParallelWorker
where RawVecInner: Sync, Arc<dyn Fn(&AgentError) -> bool + Sync + Send>: Sync, Arc<CompiledSchema>: Sync, Arc<dyn Node>: Sync,

§

impl Unpin for ParallelWorker
where *const u8 is !null: Unpin, Arc<dyn Fn(&AgentError) -> bool + Sync + Send>: Unpin, Arc<CompiledSchema>: Unpin, Arc<dyn Node>: Unpin,

§

impl UnsafeUnpin for ParallelWorker
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn Fn(&AgentError) -> bool + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&AgentError) -> bool + Sync + Send>>: UnsafeUnpin, *const ArcInner<CompiledSchema> is !null: UnsafeUnpin, PhantomData<ArcInner<CompiledSchema>>: UnsafeUnpin, *const ArcInner<dyn Node> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Node>>: UnsafeUnpin,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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