pub struct Task {
pub id: TaskId,
pub name: String,
pub payload: Bytes,
pub priority: TaskPriority,
pub timeout: Duration,
pub max_retries: u32,
pub retry_count: u32,
pub dependencies: Vec<TaskId>,
pub metadata: TaskMetadata,
pub status: TaskStatus,
pub result: Option<TaskResult>,
}Expand description
A task to be executed in the cluster
Fields§
§id: TaskIdUnique task identifier
name: StringTask name/label
payload: BytesTask payload (serialized input)
priority: TaskPriorityTask priority
timeout: DurationMaximum execution time
max_retries: u32Maximum retry attempts
retry_count: u32Current retry attempt
dependencies: Vec<TaskId>Task dependencies (must complete before this task runs)
metadata: TaskMetadataTask metadata
status: TaskStatusTask status
result: Option<TaskResult>Task result (if completed)
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(name: impl Into<String>, payload: Bytes) -> Task
pub fn new(name: impl Into<String>, payload: Bytes) -> Task
Create a new task with the given name and payload
Sourcepub fn with_priority(self, priority: TaskPriority) -> Task
pub fn with_priority(self, priority: TaskPriority) -> Task
Set task priority
Sourcepub fn with_timeout(self, timeout: Duration) -> Task
pub fn with_timeout(self, timeout: Duration) -> Task
Set task timeout
Sourcepub fn with_max_retries(self, max_retries: u32) -> Task
pub fn with_max_retries(self, max_retries: u32) -> Task
Set maximum retries
Sourcepub fn with_dependency(self, task_id: TaskId) -> Task
pub fn with_dependency(self, task_id: TaskId) -> Task
Add a dependency
Sourcepub fn increment_retry(&mut self)
pub fn increment_retry(&mut self)
Increment retry count
Sourcepub fn transition_to(
&mut self,
new_status: TaskStatus,
) -> Result<(), PolarisError>
pub fn transition_to( &mut self, new_status: TaskStatus, ) -> Result<(), PolarisError>
Transition to a new status
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Task, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Task, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Task
impl Serialize for Task
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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 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