pub struct SwarmCoordinator { /* private fields */ }Expand description
The swarm coordinator manages concurrent swarm tasks across available fighters.
Implementations§
Source§impl SwarmCoordinator
impl SwarmCoordinator
Sourcepub fn register_fighter(&self, fighter_id: FighterId)
pub fn register_fighter(&self, fighter_id: FighterId)
Register a fighter as available for swarm work.
Sourcepub fn register_fighter_with_capabilities(
&self,
fighter_id: FighterId,
capabilities: Vec<String>,
)
pub fn register_fighter_with_capabilities( &self, fighter_id: FighterId, capabilities: Vec<String>, )
Register a fighter with specific capabilities.
Sourcepub fn unregister_fighter(&self, fighter_id: &FighterId)
pub fn unregister_fighter(&self, fighter_id: &FighterId)
Remove a fighter from the available pool.
Sourcepub fn record_heartbeat(&self, fighter_id: &FighterId)
pub fn record_heartbeat(&self, fighter_id: &FighterId)
Record a heartbeat from a fighter to track liveness.
Sourcepub fn decompose_task(&self, description: &str) -> Vec<SwarmSubtask>
pub fn decompose_task(&self, description: &str) -> Vec<SwarmSubtask>
Decompose a task description into subtasks.
Uses intelligent splitting: tries paragraph breaks first, then sentence boundaries, then falls back to line-based splitting.
Sourcepub fn create_task(&self, description: String) -> Uuid
pub fn create_task(&self, description: String) -> Uuid
Create a new swarm task from a description.
The task is automatically decomposed into subtasks.
Sourcepub fn create_task_with_subtasks(
&self,
description: String,
subtasks: Vec<SwarmSubtask>,
) -> Uuid
pub fn create_task_with_subtasks( &self, description: String, subtasks: Vec<SwarmSubtask>, ) -> Uuid
Create a swarm task with explicit subtasks (for pipeline or dependent tasks).
Sourcepub async fn assign_subtasks(
&self,
task_id: &Uuid,
) -> PunchResult<Vec<(Uuid, FighterId)>>
pub async fn assign_subtasks( &self, task_id: &Uuid, ) -> PunchResult<Vec<(Uuid, FighterId)>>
Assign pending subtasks to available fighters using load balancing and capability matching.
Returns a list of (subtask_id, fighter_id) assignments.
Sourcepub async fn complete_subtask(
&self,
task_id: &Uuid,
subtask_id: &Uuid,
result: String,
) -> PunchResult<()>
pub async fn complete_subtask( &self, task_id: &Uuid, subtask_id: &Uuid, result: String, ) -> PunchResult<()>
Report the completion of a subtask.
Sourcepub async fn fail_subtask(
&self,
task_id: &Uuid,
subtask_id: &Uuid,
error: String,
) -> PunchResult<()>
pub async fn fail_subtask( &self, task_id: &Uuid, subtask_id: &Uuid, error: String, ) -> PunchResult<()>
Report the failure of a subtask.
Sourcepub async fn reassign_failed_subtask(
&self,
task_id: &Uuid,
subtask_id: &Uuid,
) -> PunchResult<Option<FighterId>>
pub async fn reassign_failed_subtask( &self, task_id: &Uuid, subtask_id: &Uuid, ) -> PunchResult<Option<FighterId>>
Reassign a failed subtask to a different fighter.
Sourcepub fn detect_stale_fighters(&self) -> Vec<FighterId>
pub fn detect_stale_fighters(&self) -> Vec<FighterId>
Detect stale or failed fighters and reassign their work.
Returns a list of fighter IDs that were detected as stale/failed.
Sourcepub fn mark_unhealthy(&self, fighter_id: &FighterId)
pub fn mark_unhealthy(&self, fighter_id: &FighterId)
Mark a fighter as unhealthy (will not receive new assignments).
Sourcepub fn mark_healthy(&self, fighter_id: &FighterId)
pub fn mark_healthy(&self, fighter_id: &FighterId)
Mark a fighter as healthy again.
Sourcepub async fn get_task(&self, task_id: &Uuid) -> Option<SwarmTask>
pub async fn get_task(&self, task_id: &Uuid) -> Option<SwarmTask>
Get the current state of a swarm task.
Sourcepub async fn get_progress(&self, task_id: &Uuid) -> Option<f64>
pub async fn get_progress(&self, task_id: &Uuid) -> Option<f64>
Get the progress of a swarm task (0.0 to 1.0).
Sourcepub async fn get_progress_report(
&self,
task_id: &Uuid,
) -> Option<ProgressReport>
pub async fn get_progress_report( &self, task_id: &Uuid, ) -> Option<ProgressReport>
Get a detailed progress report for a swarm task.
Sourcepub fn list_task_ids(&self) -> Vec<Uuid>
pub fn list_task_ids(&self) -> Vec<Uuid>
List all active swarm task IDs.
Sourcepub fn available_fighter_count(&self) -> usize
pub fn available_fighter_count(&self) -> usize
Get the number of available healthy fighters.
Sourcepub fn get_fighter_loads(&self) -> Vec<FighterLoad>
pub fn get_fighter_loads(&self) -> Vec<FighterLoad>
Get load information for all fighters.
Sourcepub fn remove_task(&self, task_id: &Uuid) -> bool
pub fn remove_task(&self, task_id: &Uuid) -> bool
Remove a completed or failed swarm task.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwarmCoordinator
impl !RefUnwindSafe for SwarmCoordinator
impl Send for SwarmCoordinator
impl Sync for SwarmCoordinator
impl Unpin for SwarmCoordinator
impl UnsafeUnpin for SwarmCoordinator
impl !UnwindSafe for SwarmCoordinator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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