Skip to main content

TaskBuilder

Struct TaskBuilder 

Source
pub struct TaskBuilder<Args> { /* private fields */ }
Expand description

Builder for creating Task instances with optional configuration

Implementations§

Source§

impl<Args> TaskBuilder<Args>

Source

pub fn new(args: Args) -> Self

Create a new TaskBuilder with the required args

Source

pub fn with_metadata(self, metadata: MetadataStore) -> Self

Set the task’s metadata

Source

pub fn with_data(self, data: Extensions) -> Self

Set the task’s runtime data

Source

pub fn data<D: Clone + Send + Sync + 'static>(self, value: D) -> Self

Insert a value into the task’s data context

Source

pub fn metadata<M>(self, value: &M) -> Self
where M: Metadata, M::Error: Debug,

Insert a value into the task’s metadata

Source

pub fn task_id(self, task_id: TaskId) -> Self

Set the task ID

Source

pub fn attempt(self, attempt: usize) -> Self

Set the attempt information

Source

pub fn status(self, status: Status) -> Self

Set the task status

Source

pub fn max_attempts(self, max_attempts: usize) -> Self

Set the maximum number of attempts allowed for the task

Source

pub fn priority(self, priority: usize) -> Self

Set the priority of the task

Source

pub fn queue(self, queue: Queue) -> Self

Set the queue this task belongs to

Source

pub fn run_at_timestamp(self, timestamp: u64) -> Self

Schedule the task to run at a specific Unix timestamp

Source

pub fn run_at_time(self, time: SystemTime) -> Self

Schedule the task to run at a specific SystemTime

Source

pub fn run_after(self, delay: Duration) -> Self

Schedule the task to run after a delay from now

Source

pub fn run_in_seconds(self, seconds: u64) -> Self

Schedule the task to run in the specified number of seconds

Source

pub fn run_in_minutes(self, minutes: u64) -> Self

Schedule the task to run in the specified number of minutes

Source

pub fn run_in_hours(self, hours: u64) -> Self

Schedule the task to run in the specified number of hours

Source

pub fn idempotency_key<S: AsRef<str>>(self, idempotency_key: S) -> Self

Set the idempotency key

Source

pub fn done_at(self, done_at: Option<u64>) -> Self

Set the time the task was completed

Source

pub fn lock_at(self, lock_at: Option<u64>) -> Self

Set the time the task was locked

Source

pub fn lock_by(self, lock_by: Option<String>) -> Self

Set the worker/process identifier holding the lock on this task

Source

pub fn build(self) -> Task<Args>

Build the Task with default context

Source§

impl<Args> TaskBuilder<Args>

Source

pub fn try_map_args<F, NewArgs, Err>( self, f: F, ) -> Result<TaskBuilder<NewArgs>, Err>
where F: FnOnce(Args) -> Result<NewArgs, Err>,

Maps the args field using the provided function, returning a result.

Source

pub fn map_args<F, NewArgs>(self, f: F) -> TaskBuilder<NewArgs>
where F: FnOnce(Args) -> NewArgs,

Maps the args field using the provided function, returning the new args.

Source

pub fn map_context<F>(self, f: F) -> Self

Maps only the execution_context field.

Trait Implementations§

Source§

impl<Args: Debug> Debug for TaskBuilder<Args>

Source§

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

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

impl<'de, Args> Deserialize<'de> for TaskBuilder<Args>
where Args: Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl<Args> Serialize for TaskBuilder<Args>
where Args: Serialize,

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<Args> !RefUnwindSafe for TaskBuilder<Args>

§

impl<Args> !UnwindSafe for TaskBuilder<Args>

§

impl<Args> Freeze for TaskBuilder<Args>
where Args: Freeze,

§

impl<Args> Send for TaskBuilder<Args>
where Args: Send,

§

impl<Args> Sync for TaskBuilder<Args>
where Args: Sync,

§

impl<Args> Unpin for TaskBuilder<Args>
where Args: Unpin,

§

impl<Args> UnsafeUnpin for TaskBuilder<Args>
where Args: UnsafeUnpin,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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