Struct celery::CeleryBuilder

source ·
pub struct CeleryBuilder { /* private fields */ }
Expand description

Used to create a Celery app with a custom configuration.

Implementations§

source§

impl CeleryBuilder

source

pub fn new(name: &str, broker_url: &str) -> Self

Get a CeleryBuilder for creating a Celery app with a custom configuration.

source

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.

source

pub fn default_queue(self, queue_name: &str) -> Self

Set the name of the default queue to something other than “celery”.

source

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).

source

pub fn heartbeat(self, heartbeat: Option<u16>) -> Self

Set the broker heartbeat. The default value depends on the broker implementation.

source

pub fn task_time_limit(self, task_time_limit: u32) -> Self

Set an app-level time limit for tasks (see TaskOptions::time_limit).

source

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.

source

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).

source

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).

source

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).

source

pub fn task_retry_for_unexpected(self, retry_for_unexpected: bool) -> Self

Set whether by default UnexpectedErrors should be retried for (see TaskOptions::retry_for_unexpected).

source

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).

source

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

Set default serialization format a task will have (see TaskOptions::content_type).

source

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

Add a routing rule.

source

pub fn broker_connection_timeout(self, timeout: u32) -> Self

Set a timeout in seconds before giving up establishing a connection to a broker.

source

pub fn broker_connection_retry(self, retry: bool) -> Self

Set whether or not to automatically try to re-establish connection to the AMQP broker.

source

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.

source

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.

source

pub async fn build(self) -> Result<Celery, CeleryError>

Construct a Celery app with the current configuration.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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