pub struct TaskRecord {
pub id: String,
pub state: TaskState,
pub attempts: u32,
pub created_at: u64,
pub updated_at: u64,
pub started_at: Option<u64>,
pub finished_at: Option<u64>,
pub output: Option<Value>,
pub error: Option<String>,
pub metadata: HashMap<String, String>,
}Expand description
A persisted snapshot of a task’s execution history.
This is the unit of durability: the executor saves one record per task so that a crashed run can be recovered without re-executing completed work.
Fields§
§id: StringStable task identifier.
state: TaskStateCurrent lifecycle state.
attempts: u32Number of execution attempts made so far.
created_at: u64When the record was first created (ms since epoch).
updated_at: u64When the record was last modified (ms since epoch).
started_at: Option<u64>When execution most recently started, if ever.
finished_at: Option<u64>When execution most recently finished, if ever.
output: Option<Value>The successful output, if any.
error: Option<String>The last error message, if any.
metadata: HashMap<String, String>Arbitrary user/system metadata.
Implementations§
Source§impl TaskRecord
impl TaskRecord
Sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Create a fresh record in the TaskState::Pending state.
Sourcepub fn transition(&mut self, state: TaskState) -> bool
pub fn transition(&mut self, state: TaskState) -> bool
Transition the record to state, updating updated_at.
Returns false (and leaves the record untouched) if the transition is
not allowed by TaskState::can_transition_to.
Sourcepub fn duration_millis(&self) -> Option<u64>
pub fn duration_millis(&self) -> Option<u64>
Wall-clock execution duration in milliseconds, if both endpoints exist.
Trait Implementations§
Source§impl Clone for TaskRecord
impl Clone for TaskRecord
Source§fn clone(&self) -> TaskRecord
fn clone(&self) -> TaskRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more