pub struct TaskOptions {
pub time_limit: Option<u32>,
pub hard_time_limit: Option<u32>,
pub max_retries: Option<u32>,
pub min_retry_delay: Option<u32>,
pub max_retry_delay: Option<u32>,
pub retry_for_unexpected: Option<bool>,
pub acks_late: Option<bool>,
pub content_type: Option<MessageContentType>,
}
Expand description
Configuration options pertaining to a task.
These are set at either the app level (pertaining to all registered tasks), the task level (pertaining to a specific task), or - in some cases - at the request / signature level (pertaining only to an individual task request).
The order of precedence is determined by how specific the given configuration option is. That is, options set at the request level have the highest precedence, followed by options set at the task level, and lastly the app level.
For example, if time_limit: Some(10)
is set at the app level through the
task_time_limit
option,
then every task will use a time limit of 10 seconds unless some other time limit is specified in the
task definition or in a
task signature for that task.
Fields§
§time_limit: Option<u32>
Time limit for a task.
If set to Some(n)
, the task will be interrupted and fail with a
TimeoutError
if it runs longer than n
seconds.
This can be set with
task_time_limit
at the app level,time_limit
at the task level, andwith_time_limit
at the request / signature level.
If this option is left unspecified, the default behavior will be to enforce no time limit.
Note, however, that only non-blocking tasks can be interrupted, so it’s important to use async functions within task implementations whenever they are available.
hard_time_limit: Option<u32>
The time_limit
option is equivalent to the “soft time
limit”
option when sending tasks to a Python consumer.
If you desire to set a “hard time limit”, use this option.
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.
This can be set with
task_hard_time_limit
at the app level,hard_time_limit
at the task level, andwith_hard_time_limit
at the request / signature level.
max_retries: Option<u32>
Maximum number of retries for this task.
This can be set with
task_max_retries
at the app level, andmax_retries
at the task level.
If this option is left unspecified, the default behavior will be to retry tasks indefinitely.
min_retry_delay: Option<u32>
Minimum retry delay (in seconds).
This can be set with
task_min_retry_delay
at the app level, andmin_retry_delay
at the task level.
If this option is left unspecified, the default behavior will be to use 0 as the
minimum. In practice this means the first retry will usually be delayed only a couple hundred milliseconds.
The delay for subsequent retries will increase exponentially (with random jitter) before
maxing out at max_retry_delay
.
max_retry_delay: Option<u32>
Maximum retry delay (in seconds).
This can be set with
task_max_retry_delay
at the app level, andmax_retry_delay
at the task level.
If this option is left unspecified, the default behavior will be to cap delays at 1 hour (3600 seconds) with some random jitter.
retry_for_unexpected: Option<bool>
Whether or not to retry the task when an UnexpectedError
is returned.
This can be set with
task_retry_for_unexpected
at the app level, andretry_for_unexpected
at the task level.
If this option is left unspecified, the default behavior will be to retry for these errors.
acks_late: Option<bool>
Whether messages will be acknowledged after the task has been executed or before.
If your tasks are
idempotent
then it is recommended that you set this to true
.
This can be set with
If this option is left unspecified, the default behavior will be to ack early.
content_type: Option<MessageContentType>
Which serialization format to use for task messages.
This can be set with
task_content_type
at the app level, andcontent_type
at the task level.with_content_type
at the request / signature level.
Trait Implementations§
Source§impl Clone for TaskOptions
impl Clone for TaskOptions
Source§fn clone(&self) -> TaskOptions
fn clone(&self) -> TaskOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more