pub struct Task { /* private fields */ }Expand description
Unified task resource.
Every task is represented as a single resource with three sections:
status- observed state: current phase, attempts, errors (TaskStatus)spec- desired state: what to run and how (TaskSpec)metadata- identity, versioning, timestamps (ObjectMeta)
§Also
TaskSpecdesired state (what to run, how to restart).TaskStatusobserved state (phase, attempt, exit code).TaskRunper-attempt execution record.ObjectMetaidentity and versioning.TaskPhaselifecycle state machine.
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(id: TaskId, spec: TaskSpec) -> Self
pub fn new(id: TaskId, spec: TaskSpec) -> Self
Create a new task in TaskPhase::Pending phase.
Sourcepub fn metadata(&self) -> &ObjectMeta
pub fn metadata(&self) -> &ObjectMeta
Resource metadata (identity, resource_version, timestamps).
Sourcepub fn status(&self) -> &TaskStatus
pub fn status(&self) -> &TaskStatus
Observed state (phase, attempt, exit code, error).
Sourcepub fn into_parts(self) -> (ObjectMeta, TaskSpec, TaskStatus)
pub fn into_parts(self) -> (ObjectMeta, TaskSpec, TaskStatus)
Destructure into (metadata, spec, status). Used by transport
layers that need owned fields for serialization into wire types.
Sourcepub fn transition_starting(&mut self)
pub fn transition_starting(&mut self)
Transition the task into a new attempt: bumps attempt counter, sets phase to Running, clears error/exit_code.
Sourcepub fn transition_finished(
&mut self,
phase: TaskPhase,
error: Option<String>,
exit_code: Option<i32>,
) -> ModelResult<()>
pub fn transition_finished( &mut self, phase: TaskPhase, error: Option<String>, exit_code: Option<i32>, ) -> ModelResult<()>
Transition the current attempt into a terminal phase with optional error and exit code.
Rejects illegal transitions:
- target phase must be terminal (see
TaskPhase::is_terminal); finishing intoPendingorRunningis a logic bug upstream.
Bumps resource_version.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Task
impl StructuralPartialEq for Task
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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
Mutably borrows from an owned value. Read more