Skip to main content

Observer

Trait Observer 

Source
pub trait Observer: Send + Sync {
    // Provided methods
    fn on_executor_up(&self) { ... }
    fn on_executor_down(&self) { ... }
    fn on_executor_error(&self, _e: &ExecutorError) { ... }
    fn on_app_start(&self, _task: TaskId, _app: u32, _instance: Option<u32>) { ... }
    fn on_app_stop(&self, _task: TaskId) { ... }
    fn on_app_error(&self, _task: TaskId, _e: &(dyn Error + 'static)) { ... }
    fn on_send_event(&self, _task: TaskId, _ev: UserEvent) { ... }
    fn on_task_fault(&self, _task: TaskId, _reason: FaultReason) { ... }
    fn on_task_clear(&self, _task: TaskId) { ... }
    fn on_executor_fault(&self, _reason: ExecutorFaultReason) { ... }
    fn on_executor_clear(&self) { ... }
}
Expand description

Lifecycle observer invoked by the executor at well-defined points.

All methods have no-op defaults. The executor never blocks on observer callbacks — heavy work should be queued internally.

Provided Methods§

Source

fn on_executor_up(&self)

Called once just before the dispatch loop begins.

Source

fn on_executor_down(&self)

Called once just after the dispatch loop finishes cleanly.

Source

fn on_executor_error(&self, _e: &ExecutorError)

Called when the dispatch loop returns an error.

Source

fn on_app_start(&self, _task: TaskId, _app: u32, _instance: Option<u32>)

Called before an item with app_id().is_some() runs (per invocation).

Source

fn on_app_stop(&self, _task: TaskId)

Called after such an item runs.

Source

fn on_app_error(&self, _task: TaskId, _e: &(dyn Error + 'static))

Called when an item returns Err or panics.

Source

fn on_send_event(&self, _task: TaskId, _ev: UserEvent)

Called when an item invokes Context::send_event.

Source

fn on_task_fault(&self, _task: TaskId, _reason: FaultReason)

Called once when a task transitions from Running to Faulted (per-task budget overrun, REQ_0070). The cascade transition triggered by an executor-wide fault does NOT fire this hook — see Observer::on_executor_fault. REQ_0073.

Source

fn on_task_clear(&self, _task: TaskId)

Called once when a task transitions from Faulted back to Running (manual clear via Executor::clear_task_fault).

Source

fn on_executor_fault(&self, _reason: ExecutorFaultReason)

Called once when the executor transitions from Running to Faulted (executor-wide iteration budget breach, REQ_0071).

Source

fn on_executor_clear(&self)

Called once when the executor transitions from Faulted back to Running (manual clear via Executor::clear_executor_fault).

Implementors§