pub struct CeleryBuilder { /* private fields */ }
Expand description
Used to create a Celery
app with a custom configuration.
Implementations§
Source§impl CeleryBuilder
impl CeleryBuilder
Sourcepub fn new(name: &str, broker_url: &str) -> Self
pub fn new(name: &str, broker_url: &str) -> Self
Get a CeleryBuilder
for creating a Celery
app with a custom configuration.
Sourcepub fn hostname(self, hostname: &str) -> Self
pub fn hostname(self, hostname: &str) -> Self
Set the node name of the app. Defaults to "{name}@{sys hostname}"
.
This field should probably be named “nodename” to avoid confusion with the system hostname, but we’re trying to be consistent with Python Celery.
Sourcepub fn default_queue(self, queue_name: &str) -> Self
pub fn default_queue(self, queue_name: &str) -> Self
Set the name of the default queue to something other than “celery”.
Sourcepub fn prefetch_count(self, prefetch_count: u16) -> Self
pub fn prefetch_count(self, prefetch_count: u16) -> Self
Set the prefetch count. The default value depends on the broker implementation, but it’s recommended that you always set this to a value that works best for your application.
This may take some tuning, as it depends on a lot of factors, such as whether your tasks are IO bound (higher prefetch count is better) or CPU bound (lower prefetch count is better).
Sourcepub fn heartbeat(self, heartbeat: Option<u16>) -> Self
pub fn heartbeat(self, heartbeat: Option<u16>) -> Self
Set the broker heartbeat. The default value depends on the broker implementation.
Sourcepub fn task_time_limit(self, task_time_limit: u32) -> Self
pub fn task_time_limit(self, task_time_limit: u32) -> Self
Set an app-level time limit for tasks (see TaskOptions::time_limit
).
Sourcepub fn task_hard_time_limit(self, task_hard_time_limit: u32) -> Self
pub fn task_hard_time_limit(self, task_hard_time_limit: u32) -> Self
Set an app-level hard time limit for tasks (see TaskOptions::hard_time_limit
).
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.
Sourcepub fn task_max_retries(self, task_max_retries: u32) -> Self
pub fn task_max_retries(self, task_max_retries: u32) -> Self
Set an app-level maximum number of retries for tasks (see TaskOptions::max_retries
).
Sourcepub fn task_min_retry_delay(self, task_min_retry_delay: u32) -> Self
pub fn task_min_retry_delay(self, task_min_retry_delay: u32) -> Self
Set an app-level minimum retry delay for tasks (see TaskOptions::min_retry_delay
).
Sourcepub fn task_max_retry_delay(self, task_max_retry_delay: u32) -> Self
pub fn task_max_retry_delay(self, task_max_retry_delay: u32) -> Self
Set an app-level maximum retry delay for tasks (see TaskOptions::max_retry_delay
).
Sourcepub fn task_retry_for_unexpected(self, retry_for_unexpected: bool) -> Self
pub fn task_retry_for_unexpected(self, retry_for_unexpected: bool) -> Self
Set whether by default UnexpectedError
s should be retried for (see
TaskOptions::retry_for_unexpected
).
Sourcepub fn acks_late(self, acks_late: bool) -> Self
pub fn acks_late(self, acks_late: bool) -> Self
Set whether by default a task is acknowledged before or after execution (see
TaskOptions::acks_late
).
Sourcepub fn task_content_type(self, content_type: MessageContentType) -> Self
pub fn task_content_type(self, content_type: MessageContentType) -> Self
Set default serialization format a task will have (see TaskOptions::content_type
).
Sourcepub fn task_route(self, pattern: &str, queue: &str) -> Self
pub fn task_route(self, pattern: &str, queue: &str) -> Self
Add a routing rule.
Sourcepub fn broker_connection_timeout(self, timeout: u32) -> Self
pub fn broker_connection_timeout(self, timeout: u32) -> Self
Set a timeout in seconds before giving up establishing a connection to a broker.
Sourcepub fn broker_connection_retry(self, retry: bool) -> Self
pub fn broker_connection_retry(self, retry: bool) -> Self
Set whether or not to automatically try to re-establish connection to the AMQP broker.
Sourcepub fn broker_connection_max_retries(self, max_retries: u32) -> Self
pub fn broker_connection_max_retries(self, max_retries: u32) -> Self
Set the maximum number of retries before we give up trying to re-establish connection to the AMQP broker.
Sourcepub fn broker_connection_retry_delay(self, retry_delay: u32) -> Self
pub fn broker_connection_retry_delay(self, retry_delay: u32) -> Self
Set the number of seconds to wait before re-trying the connection with the broker.