pub struct TaskDefinition<T = ()> {
pub target: UnixNanos,
pub worker_selector: WorkerSelector,
pub data: Vec<u8>,
pub data_format: TaskDataFormat,
pub labels: HashMap<String, Value>,
pub timeout: TimeoutPolicy,
/* private fields */
}
Expand description
An untyped complete task definition that can be added to the queue.
Fields§
§target: UnixNanos
The target time of the task execution.
worker_selector: WorkerSelector
The worker selector of the task.
data: Vec<u8>
Arbitrary task data that is passed to the workers.
data_format: TaskDataFormat
The input data format.
labels: HashMap<String, Value>
Arbitrary task labels.
timeout: TimeoutPolicy
An optional timeout policy.
Implementations§
Source§impl<T> TaskDefinition<T>
impl<T> TaskDefinition<T>
Sourcepub fn with_timeout(self, timeout: impl Into<TimeoutPolicy>) -> Self
pub fn with_timeout(self, timeout: impl Into<TimeoutPolicy>) -> Self
Set a timeout policy.
Sourcepub fn at(self, target: OffsetDateTime) -> Self
pub fn at(self, target: OffsetDateTime) -> Self
Set the target execution time of the new task.
Sourcepub fn at_unix(self, target: UnixNanos) -> Self
pub fn at_unix(self, target: UnixNanos) -> Self
Schedule the task at the given unix nanosecond duration.
Sourcepub fn after(self, duration: Duration) -> Self
pub fn after(self, duration: Duration) -> Self
Set the target execution time of the new task to be after the given duration.
§Panics
Panics if the system time is before UNIX epoch.
Sourcepub fn with_worker_selector(self, selector: impl Into<WorkerSelector>) -> Self
pub fn with_worker_selector(self, selector: impl Into<WorkerSelector>) -> Self
Set the worker selector for the given task.
Sourcepub fn with_label(self, name: &str, value: impl Serialize) -> Self
pub fn with_label(self, name: &str, value: impl Serialize) -> Self
Sourcepub fn cast<U>(self) -> TaskDefinition<U>
pub fn cast<U>(self) -> TaskDefinition<U>
Cast the task to a different task type,
or to erase the task type replacing it with ()
.
This is not required in most circumstances.
Trait Implementations§
Source§impl<T> Clone for TaskDefinition<T>
impl<T> Clone for TaskDefinition<T>
Source§impl<T: Debug> Debug for TaskDefinition<T>
impl<T: Debug> Debug for TaskDefinition<T>
Source§impl<'de, T> Deserialize<'de> for TaskDefinition<T>
impl<'de, T> Deserialize<'de> for TaskDefinition<T>
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<T> Freeze for TaskDefinition<T>
impl<T> RefUnwindSafe for TaskDefinition<T>where
T: RefUnwindSafe,
impl<T> Send for TaskDefinition<T>where
T: Send,
impl<T> Sync for TaskDefinition<T>where
T: Sync,
impl<T> Unpin for TaskDefinition<T>where
T: Unpin,
impl<T> UnwindSafe for TaskDefinition<T>where
T: UnwindSafe,
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