pub struct TaskBuilder<'a> { /* private fields */ }
Expand description

Cycle plan task builder.

Implementations§

source§

impl<'a> TaskBuilder<'a>

source

pub fn set_frequency(&mut self, frequency: Frequency<'a>) -> &mut Self

👎Deprecated

Set task Frequency. This api will be deprecated in the future, please use set_frequency_once_* | set_frequency_count_down_* | set_frequency_repeated_* etc.

source

pub fn set_frequency_by_candy<T: Into<CandyCronStr>>( &mut self, frequency: CandyFrequency<T> ) -> &mut Self

👎Deprecated

Set task Frequency by customized CandyCronStr. In order to build a high-performance, highly reusable TaskBuilder that maintains the Copy feature .

when supporting building from CandyCronStr , here actively leaks memory for create a str-slice (because str-slice support Copy, String does not)

We need to call free manually before TaskBuilder drop or before we leave the scope.

Explain: Explicitly implementing both Drop and Copy trait on a type is currently disallowed.

This feature can make some sense in theory, but the current implementation is incorrect and can lead to memory unsafety (see (issue #20126), so it has been disabled for now. This api will be deprecated in the future, please use set_frequency_*_by_candy etc.

source

pub fn set_task_id(&mut self, task_id: u64) -> &mut Self

Set task-id.

source

pub fn set_maximum_running_time( &mut self, maximum_running_time: u64 ) -> &mut Self

Set maximum execution time (optional).

source

pub fn set_maximum_parallel_runnable_num( &mut self, maximum_parallel_runnable_num: u64 ) -> &mut Self

Set a task with the maximum number of parallel runs (optional).

source

pub fn set_schedule_iterator_time_zone( &mut self, schedule_iterator_time_zone: ScheduleIteratorTimeZone ) -> &mut Self

Set time zone for cron-expression iteration time.

source

pub fn spawn_async_routine<F: Fn() -> U + 'static + Send, U: Future + 'static + Send>( self, routine: F ) -> Result<Task, TaskError>

Spawn a task with async-routine.

source

pub fn spawn_routine<F: Fn() + 'static + Send + Clone>( self, routine: F ) -> Result<Task, TaskError>

Spawn a task with sync-routine.

source

pub fn free(&mut self)

If we call set_frequency_by_candy explicitly and generate TaskBuilder, We need to call free manually before TaskBuilder drop or before we leave the scope.

Explain: Explicitly implementing both Drop and Copy trait on a type is currently disallowed. This feature can make some sense in theory, but the current implementation is incorrect and can lead to memory unsafety (see (issue #20126), so it has been disabled for now. So I can’t go through Drop and handle these automatically.

source§

impl<'a> TaskBuilder<'a>

source

pub fn set_frequency_once_by_cron_str(&mut self, cron_str: &'a str) -> &mut Self

Task execution frequency: execute only once, set by cron expression.

source

pub fn set_frequency_repeated_by_cron_str( &mut self, cron_str: &'a str ) -> &mut Self

Task execution frequency: countdown execution, set by cron expression.

source

pub fn set_frequency_count_down_by_cron_str( &mut self, cron_str: &'a str, count_down: u64 ) -> &mut Self

Task execution frequency: execute repeatedly, set by cron expression.

source

pub fn set_frequency_once_by_seconds(&mut self, seconds: u64) -> &mut Self

Task execution frequency: execute only once, set by seconds num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_repeated_by_seconds(&mut self, seconds: u64) -> &mut Self

Task execution frequency: countdown execution, set by seconds num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_count_down_by_seconds( &mut self, seconds: u64, count_down: u64 ) -> &mut Self

Task execution frequency: execute repeatedly, set by seconds num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_once_by_minutes(&mut self, minutes: u64) -> &mut Self

Task execution frequency: execute only once, set by minutes num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_repeated_by_minutes(&mut self, minutes: u64) -> &mut Self

Task execution frequency: countdown execution, set by minutes num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_count_down_by_minutes( &mut self, minutes: u64, count_down: u64 ) -> &mut Self

Task execution frequency: execute repeatedly, set by minutes num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_once_by_hours(&mut self, hours: u64) -> &mut Self

Task execution frequency: execute only once, set by hours num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_repeated_by_hours(&mut self, hours: u64) -> &mut Self

Task execution frequency: execute repeatedly, set by hours num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_count_down_by_hours( &mut self, hours: u64, count_down: u64 ) -> &mut Self

Task execution frequency: countdown execution, set by hours num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_once_by_days(&mut self, days: u64) -> &mut Self

Task execution frequency: execute only once, set by days num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_repeated_by_days(&mut self, days: u64) -> &mut Self

Task execution frequency: execute repeatedly, set by days num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_count_down_by_days( &mut self, days: u64, count_down: u64 ) -> &mut Self

Task execution frequency: countdown execution, set by days num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

source

pub fn set_frequency_once_by_timestamp_seconds( &mut self, timestamp_seconds: u64 ) -> &mut Self

Task execution frequency: execute only once, set by timestamp-seconds num.

Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.

Trait Implementations§

source§

impl<'a> Clone for TaskBuilder<'a>

source§

fn clone(&self) -> TaskBuilder<'a>

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<'a> Debug for TaskBuilder<'a>

source§

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

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

impl<'a> Default for TaskBuilder<'a>

source§

fn default() -> TaskBuilder<'a>

Returns the “default value” for a type. Read more
source§

impl<'a> Copy for TaskBuilder<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for TaskBuilder<'a>

§

impl<'a> Send for TaskBuilder<'a>

§

impl<'a> Sync for TaskBuilder<'a>

§

impl<'a> Unpin for TaskBuilder<'a>

§

impl<'a> UnwindSafe for TaskBuilder<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<T> ToOwned for T
where 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 T
where 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 T
where 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