Skip to main content

TaskHook

Trait TaskHook 

Source
pub trait TaskHook:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn on_accepted(&self, _task_id: TaskId) { ... }
    fn on_rejected(&self, _error: &SubmissionError) { ... }
    fn on_started(&self, _task_id: TaskId) { ... }
    fn on_finished(&self, _task_id: TaskId, _status: TaskStatus) { ... }
}
Expand description

Observes task lifecycle events emitted by executors and executor services.

Hook events follow a strict lifecycle ordering for each task. A rejected submission emits only Self::on_rejected and never receives a task id. An accepted submission emits Self::on_accepted before any later Self::on_started or Self::on_finished event for the same task. on_started is emitted only when the task actually begins running; a task cancelled before start or abandoned by its accepted runner endpoint may emit on_finished without on_started.

Executors contain hook panics so hook implementations cannot break task execution or result publication.

Provided Methods§

Source

fn on_accepted(&self, _task_id: TaskId)

Called after a task is accepted.

§Parameters
  • task_id - Identifier assigned to the accepted task.
Source

fn on_rejected(&self, _error: &SubmissionError)

Called when a submitted task is rejected.

Rejected tasks do not have task ids and never emit started or finished events.

§Parameters
  • error - Submission error explaining the rejection.
Source

fn on_started(&self, _task_id: TaskId)

Called immediately before an accepted task starts running.

This callback is emitted after Self::on_accepted for the same task.

§Parameters
  • task_id - Identifier assigned to the accepted task.
Source

fn on_finished(&self, _task_id: TaskId, _status: TaskStatus)

Called after an accepted task reaches a terminal status.

This callback is emitted after Self::on_accepted for the same task. It is normally emitted after Self::on_started, except for pre-start cancellation or accepted runner-endpoint abandonment.

§Parameters
  • task_id - Identifier assigned to the accepted task.
  • status - Terminal status observed for the task.

Implementors§