Skip to main content

Spawner

Struct Spawner 

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

Agent-agnostic process spawner with tracking and log capture.

Manages the full lifecycle: claim → spawn → track → complete/release.

Implementations§

Source§

impl Spawner

Source

pub fn new() -> Self

Create an empty spawner with no running agents.

Source

pub fn spawn( &mut self, unit_id: &str, unit_title: &str, action: AgentAction, config: &Config, mana_dir: Option<&Path>, ) -> Result<()>

Spawn an agent for a unit.

  1. Selects the command template from config (run or plan)
  2. Substitutes {id} with the unit ID
  3. Claims the unit via mana claim
  4. Opens a log file for stdout/stderr capture
  5. Spawns the process via sh -c <cmd>
  6. Registers the process in the agents persistence file
Source

pub fn check_completed(&mut self) -> Vec<CompletedAgent>

Non-blocking check for completed agents.

Calls try_wait() on each running process. Completed agents are removed from the running map and returned. On failure, the unit claim is released.

Source

pub fn running_count(&self) -> usize

Number of currently running agents.

Source

pub fn can_spawn(&self, max_concurrent: u32) -> bool

Whether a new agent can be spawned given the concurrency limit.

Source

pub fn list_running(&self) -> Vec<&AgentProcess>

Immutable view of all running agent processes.

Source

pub fn kill_all(&mut self)

Kill all running agent processes and release their claims.

Source

pub fn shutdown_all(&mut self, grace_period: Duration)

Gracefully shutdown all running agent processes.

Sends SIGTERM first, waits up to grace_period for processes to exit, then falls back to SIGKILL for any remaining. Releases claims on all affected units.

Trait Implementations§

Source§

impl Default for Spawner

Source§

fn default() -> Self

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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.