pub struct TaskManager { /* private fields */ }Expand description
Centralized task lifecycle manager
Implementations§
Source§impl TaskManager
impl TaskManager
Sourcepub fn progress(
&self,
task_id: TaskId,
message: impl Into<String>,
) -> Result<(), TaskManagerError>
pub fn progress( &self, task_id: TaskId, message: impl Into<String>, ) -> Result<(), TaskManagerError>
Update task progress
Sourcepub fn complete(
&self,
task_id: TaskId,
output: Option<Value>,
) -> Result<(), TaskManagerError>
pub fn complete( &self, task_id: TaskId, output: Option<Value>, ) -> Result<(), TaskManagerError>
Complete a task with result
Sourcepub fn fail(
&self,
task_id: TaskId,
error: impl Into<String>,
) -> Result<(), TaskManagerError>
pub fn fail( &self, task_id: TaskId, error: impl Into<String>, ) -> Result<(), TaskManagerError>
Fail a task with error
Sourcepub fn get_result(&self, task_id: TaskId) -> Option<TaskResult>
pub fn get_result(&self, task_id: TaskId) -> Option<TaskResult>
Get task result
Sourcepub fn is_terminal(&self, task_id: TaskId) -> bool
pub fn is_terminal(&self, task_id: TaskId) -> bool
Check if task is terminal
Sourcepub fn subscribe(&self, task_id: TaskId) -> Option<Receiver<TaskEvent>>
pub fn subscribe(&self, task_id: TaskId) -> Option<Receiver<TaskEvent>>
Subscribe to task events
Returns a receiver that will receive all events for the task. The receiver is closed when the task completes.
Sourcepub fn subscribe_all(&self) -> Receiver<TaskEvent>
pub fn subscribe_all(&self) -> Receiver<TaskEvent>
Subscribe to all task events (global)
Sourcepub async fn wait(
&self,
task_id: TaskId,
) -> Result<TaskResult, TaskManagerError>
pub async fn wait( &self, task_id: TaskId, ) -> Result<TaskResult, TaskManagerError>
Wait for a task to complete
Returns the task result when the task completes.
Sourcepub fn add_child(
&self,
parent_id: TaskId,
child_id: TaskId,
) -> Result<(), TaskManagerError>
pub fn add_child( &self, parent_id: TaskId, child_id: TaskId, ) -> Result<(), TaskManagerError>
Add a child task to a parent
Sourcepub fn spawn_child(
&self,
parent_id: TaskId,
task: Task,
) -> Result<TaskId, TaskManagerError>
pub fn spawn_child( &self, parent_id: TaskId, task: Task, ) -> Result<TaskId, TaskManagerError>
Spawn a child task with the given parent ID, setting up parent-child relationship.
This is a convenience method that combines spawn + add_child in one call.
Sourcepub async fn wait_children(
&self,
parent_id: TaskId,
) -> Result<Vec<TaskResult>, TaskManagerError>
pub async fn wait_children( &self, parent_id: TaskId, ) -> Result<Vec<TaskResult>, TaskManagerError>
Wait for all child tasks of a parent to complete.
Returns a list of results for each child task.
Sourcepub fn get_children(
&self,
parent_id: TaskId,
) -> Result<Vec<TaskId>, TaskManagerError>
pub fn get_children( &self, parent_id: TaskId, ) -> Result<Vec<TaskId>, TaskManagerError>
Get all child task IDs for a parent task.
Sourcepub fn all_children_complete(&self, parent_id: TaskId) -> bool
pub fn all_children_complete(&self, parent_id: TaskId) -> bool
Check if all children of a parent task are complete.
Sourcepub fn pending_tasks(&self) -> Vec<TaskId>
pub fn pending_tasks(&self) -> Vec<TaskId>
Get pending task IDs (FIFO)
Sourcepub fn pop_pending(&self) -> Option<TaskId>
pub fn pop_pending(&self) -> Option<TaskId>
Pop the next pending task
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TaskManager
impl !RefUnwindSafe for TaskManager
impl Send for TaskManager
impl Sync for TaskManager
impl Unpin for TaskManager
impl UnsafeUnpin for TaskManager
impl !UnwindSafe for TaskManager
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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