pub struct Task {
pub id: TaskId,
pub name: String,
pub task_type: TaskType,
pub state: TaskState,
pub priority: TaskPriority,
pub retry: RetryPolicy,
pub timeout: Duration,
pub dependencies: Vec<TaskId>,
pub metadata: HashMap<String, String>,
pub retry_count: u32,
pub conditions: Vec<String>,
}Expand description
Task definition.
Fields§
§id: TaskIdUnique task identifier.
name: StringTask name.
task_type: TaskTypeTask type and configuration.
state: TaskStateCurrent state.
priority: TaskPriorityTask priority.
retry: RetryPolicyRetry policy.
timeout: DurationExecution timeout.
dependencies: Vec<TaskId>Task dependencies.
metadata: HashMap<String, String>Task metadata.
retry_count: u32Number of retry attempts so far.
conditions: Vec<String>Task conditions (must evaluate to true to run).
Implementations§
Source§impl Task
impl Task
Sourcepub fn add_dependency(&mut self, task_id: TaskId)
pub fn add_dependency(&mut self, task_id: TaskId)
Add a dependency to this task.
Sourcepub fn with_priority(self, priority: TaskPriority) -> Self
pub fn with_priority(self, priority: TaskPriority) -> Self
Set task priority.
Sourcepub fn with_retry(self, retry: RetryPolicy) -> Self
pub fn with_retry(self, retry: RetryPolicy) -> Self
Set retry policy.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set timeout.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata.
Sourcepub fn with_condition(self, condition: impl Into<String>) -> Self
pub fn with_condition(self, condition: impl Into<String>) -> Self
Add condition.
Sourcepub const fn can_execute(&self) -> bool
pub const fn can_execute(&self) -> bool
Check if task can be executed.
Sourcepub fn increment_retry(&mut self)
pub fn increment_retry(&mut self)
Increment retry count.
Sourcepub fn should_retry(&self) -> bool
pub fn should_retry(&self) -> bool
Check if should retry.
Sourcepub fn retry_delay(&self) -> Duration
pub fn retry_delay(&self) -> Duration
Get retry delay.
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
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