Skip to main content

Task

Struct Task 

Source
pub struct Task { /* private fields */ }
Expand description

Stored Task resource.

The serialized shape is apiVersion, kind, metadata, spec, status. Name, UID, and creation time are preserved by Self::apply_desired.

Implementations§

Source§

impl Task

Source

pub fn new(name: impl AsRef<str>, spec: TaskSpec) -> ModelResult<Self>

Creates a stored Task with server-owned defaults.

The UID and creation timestamp are generated, generation starts at 1, and status starts as unobserved Pending. The state store assigns the initial resource version separately.

§Errors

Returns ModelError::Invalid when the name or spec is invalid, or the entropy source is unavailable.

Source

pub fn from_manifest(manifest: TaskManifest) -> ModelResult<Self>

Creates a stored resource from a manifest.

§Errors

Returns ModelError::Invalid when the manifest is invalid or the entropy source is unavailable.

Source

pub fn from_parts( type_meta: TypeMeta, metadata: ObjectMeta, spec: TaskSpec, status: TaskStatus, ) -> ModelResult<Self>

Reconstructs a resource from persisted fields.

§Errors

Returns ModelError::Invalid when a resource invariant is violated.

Source

pub fn validate(&self) -> ModelResult<()>

Validates the complete resource.

§Errors

Returns ModelError::Invalid when GVK, metadata, spec, status, generation, or conditions are inconsistent.

Source

pub fn type_meta(&self) -> &TypeMeta

Resource type metadata.

Source

pub fn metadata(&self) -> &ObjectMeta

Resource metadata.

Source

pub fn spec(&self) -> &TaskSpec

Desired state.

Source

pub fn status(&self) -> &TaskStatus

Observed state.

Source

pub fn into_parts(self) -> (TypeMeta, ObjectMeta, TaskSpec, TaskStatus)

Returns the serialized resource fields.

Source

pub fn name(&self) -> &TaskId

Stable resource address (metadata.name).

Source

pub fn uid(&self) -> &Uid

Identity of this resource incarnation.

Source

pub fn slot(&self) -> &Slot

Logical concurrency slot.

Source

pub fn labels(&self) -> &Labels

Resource labels.

Source

pub fn phase(&self) -> &TaskPhase

Current lifecycle phase.

Source

pub fn set_resource_version( &mut self, resource_version: impl Into<String>, ) -> ModelResult<()>

Assigns a state-store resource version.

§Errors

Returns ModelError::Invalid when the value is empty.

Source

pub fn apply_desired( &mut self, labels: Labels, annotations: Annotations, spec: TaskSpec, resource_version: impl Into<String>, ) -> ModelResult<DesiredChange>

Applies caller-owned metadata and desired state.

UID and creation time are preserved. Metadata-only changes preserve generation and status. Spec changes increment generation and reset phase and attempt. The previous observedGeneration is retained.

Identical desired state returns DesiredChange::None. In that case, resource_version is not assigned.

§Errors

Returns ModelError::Invalid when metadata, spec, or a changed resource_version is invalid.

Source

pub fn mark_observed( &mut self, resource_version: impl Into<String>, ) -> ModelResult<bool>

Marks the current generation as reconciled.

Returns true when status changed. Returns false when the same generation was already reconciled.

§Errors

Returns ModelError::Invalid when a changed resource_version is empty.

Source

pub fn mark_reconciliation_pending( &mut self, resource_version: impl Into<String>, ) -> ModelResult<bool>

Reschedules reconciliation after a recorded failure.

Returns false when reconciliation is not failed. A change resets phase, attempt, exit code, and lifecycle error.

§Errors

Returns ModelError::Invalid when a changed resource_version is empty.

Source

pub fn mark_reconciliation_failed( &mut self, reason: impl Into<String>, message: impl Into<String>, resource_version: impl Into<String>, ) -> ModelResult<bool>

Records a reconciliation failure.

Desired state is retained. Execution phase and diagnostics are reset.

Returns true when status changed.

§Errors

Returns ModelError::Invalid when reason, message, or a changed resource_version is invalid.

Source

pub fn transition_starting( &mut self, generation: u64, attempt: u32, resource_version: impl Into<String>, ) -> ModelResult<bool>

Records an authoritative attempt start.

A stale generation returns false. An identical transition also returns false. Attempt numbers come from the execution source of truth.

§Errors

Returns ModelError::Invalid when the current generation has attempt zero or a changed resource_version is empty.

Source

pub fn transition_finished( &mut self, generation: u64, attempt: u32, phase: TaskPhase, error: Option<String>, exit_code: Option<i32>, resource_version: impl Into<String>, ) -> ModelResult<bool>

Records a terminal attempt phase.

A stale generation or older attempt returns false. Terminal phases are sticky. Failed may be refined to Exhausted or Timeout.

§Errors

Returns ModelError::Invalid when the current generation has attempt zero, phase is not terminal, or a changed resource_version is empty.

Source

pub fn reconcile_finished( &mut self, generation: u64, phase: TaskPhase, error: Option<String>, exit_code: Option<i32>, resource_version: impl Into<String>, ) -> ModelResult<bool>

Records an authoritative final lifecycle outcome.

Unlike Self::transition_finished, this may replace a conflicting terminal attempt phase. A stale generation or identical outcome returns false.

§Errors

Returns ModelError::Invalid when phase is not terminal for the current generation or a changed resource_version is empty.

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Task

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Task

Source§

impl From<&Task> for TaskManifest

Source§

fn from(task: &Task) -> Self

Converts to this type from the input type.
Source§

impl From<Task> for TaskManifest

Source§

fn from(task: Task) -> Self

Converts to this type from the input type.
Source§

impl JsonSchema for Task

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Task

Source§

fn eq(&self, other: &Task) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Task

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.