Struct Signature

Source
pub struct Signature<T>
where T: Task,
{ /* private fields */ }
Expand description

Wraps the parameters and execution options for a single task invocation.

When you define a task through the task attribute macro, calling T::new(...) with the arguments that your task function take will create a Signature<T>.

§Examples

use celery::prelude::*;

#[celery::task]
fn add(x: i32, y: i32) -> TaskResult<i32> {
    Ok(x + y)
}

let signature = add::new(1, 2);

Implementations§

Source§

impl<T> Signature<T>
where T: Task,

Source

pub fn new(params: T::Params) -> Self

Create a new Signature from task parameters.

Source

pub fn task_name() -> &'static str

Get the name of the task.

Source

pub fn with_queue(self, queue: &str) -> Self

Set the queue.

Source

pub fn with_countdown(self, countdown: u32) -> Self

Set the countdown.

Source

pub fn with_eta(self, eta: DateTime<Utc>) -> Self

Set the ETA.

Source

pub fn with_expires_in(self, expires_in: u32) -> Self

Set the number of seconds until the task expires.

Source

pub fn with_expires(self, expires: DateTime<Utc>) -> Self

Set the expiration time.

Source

pub fn with_content_type(self, content_type: MessageContentType) -> Self

Set the content type serialization format for the message body.

Source

pub fn with_time_limit(self, time_limit: u32) -> Self

Set a time limit (in seconds) for the task.

Source

pub fn with_hard_time_limit(self, time_limit: u32) -> Self

Set a hard time limit (in seconds) for the task.

Note that this is really only for compatability with Python workers. time_limit and hard_time_limit are treated the same by Rust workers, and if both are set, the minimum of the two will be used.

Trait Implementations§

Source§

impl<T> Clone for Signature<T>
where T: Task + Clone, T::Params: Clone,

Source§

fn clone(&self) -> Signature<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> TryCreateMessage for Signature<T>
where T: Task + Clone,

Source§

fn try_create_message(&self) -> Result<Message, ProtocolError>

Creating a message from a signature without consuming the signature requires cloning it. For one-shot conversions, directly use Message::try_from instead.

Source§

impl<T> TryFrom<Signature<T>> for Message
where T: Task,

Source§

fn try_from(task_sig: Signature<T>) -> Result<Self, Self::Error>

Get a new MessageBuilder from a task signature.

Source§

type Error = ProtocolError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl<T> Freeze for Signature<T>
where <T as Task>::Params: Freeze,

§

impl<T> RefUnwindSafe for Signature<T>
where <T as Task>::Params: RefUnwindSafe,

§

impl<T> Send for Signature<T>

§

impl<T> Sync for Signature<T>

§

impl<T> Unpin for Signature<T>
where <T as Task>::Params: Unpin,

§

impl<T> UnwindSafe for Signature<T>
where <T as Task>::Params: UnwindSafe,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T