CeleryConfig

Struct CeleryConfig 

Source
pub struct CeleryConfig {
Show 33 fields pub broker_url: String, pub result_backend: Option<String>, pub task_serializer: String, pub result_serializer: String, pub accept_content: Vec<String>, pub timezone: String, pub enable_utc: bool, pub task_track_started: bool, pub task_send_sent_event: bool, pub task_acks_late: bool, pub task_reject_on_worker_lost: bool, pub worker_concurrency: usize, pub worker_prefetch_multiplier: usize, pub worker_max_tasks_per_child: Option<usize>, pub worker_max_memory_per_child: Option<usize>, pub worker_heartbeat: u64, pub task_default_queue: String, pub task_default_exchange: String, pub task_default_exchange_type: String, pub task_default_routing_key: String, pub task_routes: HashMap<String, TaskRoute>, pub task_time_limit: Option<u64>, pub task_soft_time_limit: Option<u64>, pub task_default_retry_delay: u64, pub task_max_retries: u32, pub result_expires: u64, pub result_compression: Option<String>, pub result_compression_threshold: usize, pub task_annotations: HashMap<String, TaskConfig>, pub broker_transport_options: BrokerTransport, pub result_backend_transport_options: BackendTransport, pub beat_schedule: HashMap<String, BeatSchedule>, pub custom: HashMap<String, Value>,
}
Expand description

Celery-compatible main configuration

Fields§

§broker_url: String

Broker connection URL (CELERY_BROKER_URL)

§result_backend: Option<String>

Result backend URL (CELERY_RESULT_BACKEND)

§task_serializer: String

Task serializer format (CELERY_TASK_SERIALIZER)

§result_serializer: String

Result serializer format (CELERY_RESULT_SERIALIZER)

§accept_content: Vec<String>

Accepted content types (CELERY_ACCEPT_CONTENT)

§timezone: String

Timezone for scheduling (CELERY_TIMEZONE)

§enable_utc: bool

Use UTC timestamps (CELERY_ENABLE_UTC)

§task_track_started: bool

Track task started events (CELERY_TASK_TRACK_STARTED)

§task_send_sent_event: bool

Send task sent events (CELERY_TASK_SEND_SENT_EVENT)

§task_acks_late: bool

Acknowledge tasks late (CELERY_TASK_ACKS_LATE)

§task_reject_on_worker_lost: bool

Reject on worker lost (CELERY_TASK_REJECT_ON_WORKER_LOST)

§worker_concurrency: usize

Worker concurrency (CELERYD_CONCURRENCY)

§worker_prefetch_multiplier: usize

Worker prefetch multiplier (CELERYD_PREFETCH_MULTIPLIER)

§worker_max_tasks_per_child: Option<usize>

Maximum tasks per child before restart (CELERYD_MAX_TASKS_PER_CHILD)

§worker_max_memory_per_child: Option<usize>

Maximum memory per child in KB (CELERYD_MAX_MEMORY_PER_CHILD)

§worker_heartbeat: u64

Worker heartbeat interval in seconds (CELERY_WORKER_HEARTBEAT)

§task_default_queue: String

Task default queue (CELERY_DEFAULT_QUEUE)

§task_default_exchange: String

Task default exchange (CELERY_DEFAULT_EXCHANGE)

§task_default_exchange_type: String

Task default exchange type (CELERY_DEFAULT_EXCHANGE_TYPE)

§task_default_routing_key: String

Task default routing key (CELERY_DEFAULT_ROUTING_KEY)

§task_routes: HashMap<String, TaskRoute>

Task routes (CELERY_TASK_ROUTES)

§task_time_limit: Option<u64>

Task time limit in seconds (CELERY_TASK_TIME_LIMIT)

§task_soft_time_limit: Option<u64>

Task soft time limit in seconds (CELERY_TASK_SOFT_TIME_LIMIT)

§task_default_retry_delay: u64

Task default retry delay in seconds (CELERY_TASK_DEFAULT_RETRY_DELAY)

§task_max_retries: u32

Task max retries (CELERY_TASK_MAX_RETRIES)

§result_expires: u64

Result expires in seconds (CELERY_RESULT_EXPIRES)

§result_compression: Option<String>

Result compression (CELERY_RESULT_COMPRESSION)

§result_compression_threshold: usize

Result compression threshold in bytes

§task_annotations: HashMap<String, TaskConfig>

Task-specific configurations

§broker_transport_options: BrokerTransport

Broker transport options (CELERY_BROKER_TRANSPORT_OPTIONS)

§result_backend_transport_options: BackendTransport

Result backend transport options

§beat_schedule: HashMap<String, BeatSchedule>

Beat schedule configuration (CELERYBEAT_SCHEDULE)

§custom: HashMap<String, Value>

Custom configuration extensions

Implementations§

Source§

impl CeleryConfig

Source

pub fn new(broker_url: impl Into<String>) -> Self

Create a new configuration with broker URL

Source

pub fn with_broker_url(self, url: impl Into<String>) -> Self

Set broker URL

Source

pub fn with_result_backend(self, url: impl Into<String>) -> Self

Set result backend URL

Source

pub fn with_task_serializer(self, serializer: impl Into<String>) -> Self

Set task serializer

Source

pub fn with_result_serializer(self, serializer: impl Into<String>) -> Self

Set result serializer

Source

pub fn with_accept_content(self, content: Vec<String>) -> Self

Set accepted content types

Source

pub fn with_timezone(self, tz: impl Into<String>) -> Self

Set timezone

Source

pub const fn with_enable_utc(self, enabled: bool) -> Self

Enable/disable UTC

Source

pub const fn with_worker_concurrency(self, concurrency: usize) -> Self

Set worker concurrency

Source

pub const fn with_prefetch_multiplier(self, multiplier: usize) -> Self

Set worker prefetch multiplier

Source

pub fn with_default_queue(self, queue: impl Into<String>) -> Self

Set default queue name

Source

pub fn with_task_route(self, task: impl Into<String>, route: TaskRoute) -> Self

Add task route

Source

pub fn with_task_annotation( self, task: impl Into<String>, config: TaskConfig, ) -> Self

Add task annotation

Source

pub const fn with_result_expires(self, expires: u64) -> Self

Set result expiration

Source

pub fn with_result_compression(self, algorithm: impl Into<String>) -> Self

Enable result compression

Source

pub const fn with_compression_threshold(self, threshold: usize) -> Self

Set compression threshold

Source

pub fn with_beat_schedule( self, name: impl Into<String>, schedule: BeatSchedule, ) -> Self

Add beat schedule

Source

pub fn get_task_config(&self, task_name: &str) -> Option<&TaskConfig>

Get task configuration for a specific task

Source

pub fn get_task_route(&self, task_name: &str) -> Option<&TaskRoute>

Get task route for a specific task

Source

pub const fn result_expires_duration(&self) -> Duration

Get result expiration duration

Source

pub fn task_time_limit_duration(&self) -> Option<Duration>

Get task time limit duration

Source

pub fn task_soft_time_limit_duration(&self) -> Option<Duration>

Get task soft time limit duration

Source

pub fn from_env() -> Self

Load configuration from environment variables

Source

pub fn validate(&self) -> Result<(), String>

Validate configuration

§Errors

Returns an error if the configuration is invalid (e.g., empty broker URL, invalid concurrency, unsupported serializer).

Trait Implementations§

Source§

impl Clone for CeleryConfig

Source§

fn clone(&self) -> CeleryConfig

Returns a duplicate 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 Debug for CeleryConfig

Source§

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

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

impl Default for CeleryConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CeleryConfig

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 Serialize for CeleryConfig

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§

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