Skip to main content

taktora_executor/
monitor.rs

1//! `ExecutionMonitor` — pre/post `execute` timestamps.
2
3use crate::task_id::TaskId;
4use core::time::Duration;
5use std::time::Instant;
6
7/// Hook invoked before and after every `execute` call. Defaults are no-ops.
8pub trait ExecutionMonitor: Send + Sync {
9    /// Called immediately before an item's `execute()` is invoked.
10    fn pre_execute(&self, _task: TaskId, _at: Instant) {}
11    /// Called immediately after `execute()` returns. `ok` is `false` if the
12    /// item returned `Err` (or panicked).
13    fn post_execute(&self, _task: TaskId, _at: Instant, _took: Duration, _ok: bool) {}
14}
15
16/// No-op monitor used when the user does not configure one.
17pub struct NoopMonitor;
18impl ExecutionMonitor for NoopMonitor {}