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,
impl<T> Signature<T>where
T: Task,
Sourcepub fn with_queue(self, queue: &str) -> Self
pub fn with_queue(self, queue: &str) -> Self
Set the queue.
Sourcepub fn with_countdown(self, countdown: u32) -> Self
pub fn with_countdown(self, countdown: u32) -> Self
Set the countdown.
Sourcepub fn with_expires_in(self, expires_in: u32) -> Self
pub fn with_expires_in(self, expires_in: u32) -> Self
Set the number of seconds until the task expires.
Sourcepub fn with_expires(self, expires: DateTime<Utc>) -> Self
pub fn with_expires(self, expires: DateTime<Utc>) -> Self
Set the expiration time.
Sourcepub fn with_content_type(self, content_type: MessageContentType) -> Self
pub fn with_content_type(self, content_type: MessageContentType) -> Self
Set the content type serialization format for the message body.
Sourcepub fn with_time_limit(self, time_limit: u32) -> Self
pub fn with_time_limit(self, time_limit: u32) -> Self
Set a time limit (in seconds) for the task.
Sourcepub fn with_hard_time_limit(self, time_limit: u32) -> Self
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> TryCreateMessage for Signature<T>
impl<T> TryCreateMessage for Signature<T>
Source§fn try_create_message(&self) -> Result<Message, ProtocolError>
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.