pub struct Task {
pub id: String,
pub name: String,
pub description: Option<String>,
pub group: Option<String>,
pub priority: i32,
pub max_retry: u32,
pub timeout: Option<Duration>,
pub enabled: bool,
pub initial_delay: Option<Duration>,
pub execution_delay: Option<Duration>,
/* private fields */
}
Expand description
Schedulable task
Fields§
§id: String
§name: String
§description: Option<String>
§group: Option<String>
§priority: i32
§max_retry: u32
§timeout: Option<Duration>
§enabled: bool
§initial_delay: Option<Duration>
§execution_delay: Option<Duration>
Implementations§
Source§impl Task
impl Task
pub fn new<F, Fut>(
id: impl Into<String>,
name: impl Into<String>,
executor: F,
) -> Selfwhere
F: Fn(TaskContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = TaskResult> + Send + 'static,
Sourcepub fn with_initial_delay(self, delay: Duration) -> Self
pub fn with_initial_delay(self, delay: Duration) -> Self
Set initial delay before first execution
Sourcepub fn with_execution_delay(self, delay: Duration) -> Self
pub fn with_execution_delay(self, delay: Duration) -> Self
Set delay before each execution
pub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_group(self, group: impl Into<String>) -> Self
pub fn with_priority(self, priority: i32) -> Self
pub fn with_max_retry(self, max_retry: u32) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn enabled(self, enabled: bool) -> Self
pub async fn execute(&self, context: TaskContext) -> TaskResult
pub fn get_metadata(&self, key: &str) -> Option<&String>
Trait Implementations§
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