pub struct TaskExecutor { /* private fields */ }tasks only.Expand description
Parallel task executor with timeout and retry support.
Works directly with Arc<TaskManager> — since TaskManager uses DashMap internally,
no external RwLock is needed for concurrent access.
Implementations§
Source§impl TaskExecutor
impl TaskExecutor
Sourcepub fn new(
task_manager: Arc<TaskManager>,
config: TaskExecutorConfig,
) -> TaskExecutor
pub fn new( task_manager: Arc<TaskManager>, config: TaskExecutorConfig, ) -> TaskExecutor
Create a new task executor
Sourcepub fn with_execute_fn(
self,
f: Arc<dyn Fn(TaskContext) -> Pin<Box<dyn Future<Output = Result<String, ReactError>> + Send>> + Sync + Send>,
) -> TaskExecutor
pub fn with_execute_fn( self, f: Arc<dyn Fn(TaskContext) -> Pin<Box<dyn Future<Output = Result<String, ReactError>> + Send>> + Sync + Send>, ) -> TaskExecutor
Set a custom execution function
Sourcepub fn with_checkpoint_store(
self,
store: Arc<dyn CheckpointStore>,
) -> TaskExecutor
pub fn with_checkpoint_store( self, store: Arc<dyn CheckpointStore>, ) -> TaskExecutor
Set checkpoint store for periodic saving during execute_all
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Check if all tasks are completed
Sourcepub fn get_progress(&self) -> (usize, usize)
pub fn get_progress(&self) -> (usize, usize)
Get progress statistics
Sourcepub async fn execute_ready_tasks(
&self,
) -> Result<Vec<TaskExecutionResult>, ReactError>
pub async fn execute_ready_tasks( &self, ) -> Result<Vec<TaskExecutionResult>, ReactError>
Execute all ready tasks in parallel
Returns the number of tasks executed
Sourcepub fn cancel_task(&self, task_id: &str) -> bool
pub fn cancel_task(&self, task_id: &str) -> bool
Cancel a specific task
Marks the task as cancelled in the manager AND cancels the in-flight execution via CancellationToken, so a running spawned task is aborted.
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Cancel all tasks
Sourcepub async fn execute_all(&self) -> Result<Vec<TaskExecutionResult>, ReactError>
pub async fn execute_all(&self) -> Result<Vec<TaskExecutionResult>, ReactError>
Run the full execution loop until all tasks complete or a deadlock is detected.
This method repeatedly calls execute_ready_tasks and uses wake_dependents
after each batch to discover newly-ready tasks, eliminating polling.
Returns all execution results accumulated across batches.
Auto Trait Implementations§
impl Freeze for TaskExecutor
impl !RefUnwindSafe for TaskExecutor
impl Send for TaskExecutor
impl Sync for TaskExecutor
impl Unpin for TaskExecutor
impl UnsafeUnpin for TaskExecutor
impl !UnwindSafe for TaskExecutor
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request