Struct ora::TaskDefinition
source · pub struct TaskDefinition<T = ()> {
pub target: UnixNanos,
pub worker_selector: WorkerSelector,
pub data: Vec<u8, Global>,
pub data_format: TaskDataFormat,
pub labels: HashMap<String, Value, RandomState>,
pub timeout: TimeoutPolicy,
/* private fields */
}Expand description
An untyped complete task definition that can be added to the queue.
Fields§
§target: UnixNanosThe target time of the task execution.
worker_selector: WorkerSelectorThe worker selector of the task.
data: Vec<u8, Global>Arbitrary task data that is passed to the workers.
data_format: TaskDataFormatThe input data format.
labels: HashMap<String, Value, RandomState>Arbitrary task labels.
timeout: TimeoutPolicyAn optional timeout policy.
Implementations§
source§impl<T> TaskDefinition<T>
impl<T> TaskDefinition<T>
sourcepub fn with_timeout(
self,
timeout: impl Into<TimeoutPolicy>
) -> TaskDefinition<T>
pub fn with_timeout( self, timeout: impl Into<TimeoutPolicy> ) -> TaskDefinition<T>
Set a timeout policy.
sourcepub fn immediate(self) -> TaskDefinition<T>
pub fn immediate(self) -> TaskDefinition<T>
Schedule the task immediately.
sourcepub fn at(self, target: OffsetDateTime) -> TaskDefinition<T>
pub fn at(self, target: OffsetDateTime) -> TaskDefinition<T>
Set the target execution time of the new task.
sourcepub fn at_unix(self, target: UnixNanos) -> TaskDefinition<T>
pub fn at_unix(self, target: UnixNanos) -> TaskDefinition<T>
Schedule the task at the given unix nanosecond duration.
sourcepub fn now(self) -> TaskDefinition<T>
pub fn now(self) -> TaskDefinition<T>
Schedule the task with the current time as target.
sourcepub fn after(self, duration: Duration) -> TaskDefinition<T>
pub fn after(self, duration: Duration) -> TaskDefinition<T>
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>
) -> TaskDefinition<T>
pub fn with_worker_selector( self, selector: impl Into<WorkerSelector> ) -> TaskDefinition<T>
Set the worker selector for the given task.
sourcepub fn with_label(self, name: &str, value: impl Serialize) -> TaskDefinition<T>
pub fn with_label(self, name: &str, value: impl Serialize) -> TaskDefinition<T>
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§fn clone(&self) -> TaskDefinition<T>
fn clone(&self) -> TaskDefinition<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<T> Debug for TaskDefinition<T>where
T: Debug,
impl<T> Debug for TaskDefinition<T>where T: Debug,
source§impl<'de, T> Deserialize<'de> for TaskDefinition<T>
impl<'de, T> Deserialize<'de> for TaskDefinition<T>
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<TaskDefinition<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<TaskDefinition<T>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
source§impl<T> Serialize for TaskDefinition<T>
impl<T> Serialize for TaskDefinition<T>
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,
Auto Trait Implementations§
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<W> IntoHandler for Wwhere
W: Send + Sync + 'static,
impl<W> IntoHandler for Wwhere W: Send + Sync + 'static,
source§fn handler<T>(self) -> Arc<dyn RawHandler + Sync + Send, Global>where
Self: Handler<T>,
T: Task,
fn handler<T>(self) -> Arc<dyn RawHandler + Sync + Send, Global>where Self: Handler<T>, T: Task,
self into a RawHandler that can be registered
in workers.source§fn handler_with_selector<T>(
self,
selector: WorkerSelector
) -> Arc<dyn RawHandler + Sync + Send, Global>where
Self: Handler<T>,
T: Task,
fn handler_with_selector<T>( self, selector: WorkerSelector ) -> Arc<dyn RawHandler + Sync + Send, Global>where Self: Handler<T>, T: Task,
self into a RawHandler that can be registered
in workers with the given selector.