pub struct BackgroundAgentDispatcher { /* private fields */ }Expand description
Dispatcher for running TextAgent pipelines as background tasks.
§Example
ⓘ
let dispatcher = BackgroundAgentDispatcher::new(5); // max 5 concurrent
// From an on_turn_complete callback:
dispatcher.dispatch("compliance_check", compliance_agent.clone(), state.clone());
// Results appear in state:
// "compliance_check:result" = "No violations detected"
// OR
// "compliance_check:error" = "Agent failed: ..."Implementations§
Source§impl BackgroundAgentDispatcher
impl BackgroundAgentDispatcher
Sourcepub fn new(max_concurrent: usize) -> Self
pub fn new(max_concurrent: usize) -> Self
Create a new dispatcher with the given concurrency budget.
Sourcepub fn max_concurrent(&self) -> usize
pub fn max_concurrent(&self) -> usize
Maximum concurrent background agents.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Number of currently available permits.
Sourcepub fn dispatch(
&self,
task_name: impl Into<String>,
agent: Arc<dyn TextAgent>,
state: State,
)
pub fn dispatch( &self, task_name: impl Into<String>, agent: Arc<dyn TextAgent>, state: State, )
Dispatch a text agent to run in the background.
Results are written to state under {task_name}:result.
Errors are written to {task_name}:error.
If the budget is exhausted, the task will wait for a permit.
Sourcepub async fn is_running(&self, name: &str) -> bool
pub async fn is_running(&self, name: &str) -> bool
Check if a named task is still running.
Sourcepub async fn cancel_all(&self)
pub async fn cancel_all(&self)
Cancel all running background agents.
Sourcepub async fn active_count(&self) -> usize
pub async fn active_count(&self) -> usize
Number of tasks currently tracked (running or recently completed).
Auto Trait Implementations§
impl Freeze for BackgroundAgentDispatcher
impl !RefUnwindSafe for BackgroundAgentDispatcher
impl Send for BackgroundAgentDispatcher
impl Sync for BackgroundAgentDispatcher
impl Unpin for BackgroundAgentDispatcher
impl !UnwindSafe for BackgroundAgentDispatcher
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
Mutably borrows from an owned value. Read more