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: UnixNanos

The target time of the task execution.

§worker_selector: WorkerSelector

The worker selector of the task.

§data: Vec<u8, Global>

Arbitrary task data that is passed to the workers.

§data_format: TaskDataFormat

The input data format.

§labels: HashMap<String, Value, RandomState>

Arbitrary task labels.

§timeout: TimeoutPolicy

An optional timeout policy.

Implementations§

source§

impl<T> TaskDefinition<T>

source

pub fn with_timeout( self, timeout: impl Into<TimeoutPolicy> ) -> TaskDefinition<T>

Set a timeout policy.

source

pub fn immediate(self) -> TaskDefinition<T>

Schedule the task immediately.

source

pub fn at(self, target: OffsetDateTime) -> TaskDefinition<T>

Set the target execution time of the new task.

source

pub fn at_unix(self, target: UnixNanos) -> TaskDefinition<T>

Schedule the task at the given unix nanosecond duration.

source

pub fn now(self) -> TaskDefinition<T>

Schedule the task with the current time as target.

source

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.

source

pub fn with_worker_selector( self, selector: impl Into<WorkerSelector> ) -> TaskDefinition<T>

Set the worker selector for the given task.

source

pub fn with_label(self, name: &str, value: impl Serialize) -> TaskDefinition<T>

Set a label value.

Panics

Panics if the value is not JSON-serializable.

source

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>

source§

fn clone(&self) -> TaskDefinition<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T> Debug for TaskDefinition<T>where T: Debug,

source§

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

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

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>,

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

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,

Serialize this value into the given Serde serializer. Read more

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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<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,

Convert 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,

Convert self into a RawHandler that can be registered in workers with the given selector.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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