Skip to main content

ChildSpawner

Struct ChildSpawner 

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

Spawner for managing children within a Runner.

Implementations§

Source§

impl ChildSpawner

Source

pub fn new(parent_id: impl Into<String>, output_tx: OutputSender) -> Self

Creates a new ChildSpawner.

§Arguments
  • parent_id - ID of the parent Component/Child
  • output_tx - Sender for output events
Source

pub fn with_max_children(self, max: usize) -> Self

Sets the maximum number of children.

Source

pub fn child_count(&self) -> usize

Returns the number of active children.

Source

pub fn max_children(&self) -> usize

Returns the maximum allowed children.

Source

pub fn parent_id(&self) -> &str

Returns the parent ID.

Source

pub fn spawn( &mut self, config: ChildConfig, child: Box<dyn RunnableChild>, ) -> Result<Box<dyn ChildHandle>, SpawnError>

Spawns a child and returns a handle.

§Arguments
  • config - Configuration for the child
  • child - The RunnableChild instance
§Errors

Returns error if:

  • Max children reached
  • Child with same ID already exists
Source

pub fn spawn_async( &mut self, config: ChildConfig, child: Box<dyn RunnableChild>, ) -> Result<Box<dyn AsyncChildHandle>, SpawnError>

Spawns a child and returns an async handle.

Unlike Self::spawn(), this returns a handle that properly uses spawn_blocking for async execution.

§Arguments
  • config - Configuration for the child
  • child - The RunnableChild instance
§Errors

Returns error if:

  • Max children reached
  • Child with same ID already exists
Source

pub fn propagate_signal(&mut self, signal: &Signal)

Propagates a signal to all children.

Source

pub fn abort_all(&mut self)

Aborts all children.

Source

pub fn reap_finished(&mut self) -> Vec<(String, Status)>

Removes finished children and returns their results.

Source

pub fn child_ids(&self) -> Vec<String>

Returns the IDs of all active children.

Source

pub fn output_tx(&self) -> &OutputSender

Returns the output sender.

Source

pub fn get_child_arc( &self, id: &str, ) -> Option<Arc<Mutex<Box<dyn RunnableChild>>>>

Returns a clone of the child’s Arc for out-of-lock execution.

Used by send_to_children_batch to collect child references while briefly holding the spawner lock, then release it before running.

Source

pub fn run_child(&self, id: &str, input: Value) -> Result<ChildResult, RunError>

Runs a child by ID with the given input.

§Arguments
  • id - The child ID
  • input - Input data to pass to the child
§Returns

The child’s result, or an error if:

  • Child not found
  • Child lock failed

Trait Implementations§

Source§

impl Debug for ChildSpawner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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