pub struct TaskConstraints { /* private fields */ }Expand description
Constraints that control how a task’s runs are executed.
Implementations§
Source§impl TaskConstraints
impl TaskConstraints
Sourcepub fn new(
max_attempts: u32,
timeout_secs: Option<u64>,
concurrency_key: Option<String>,
) -> Result<Self, TaskConstraintsError>
pub fn new( max_attempts: u32, timeout_secs: Option<u64>, concurrency_key: Option<String>, ) -> Result<Self, TaskConstraintsError>
Creates constraints with validation of invariant-sensitive fields.
Sourcepub fn validate(&self) -> Result<(), TaskConstraintsError>
pub fn validate(&self) -> Result<(), TaskConstraintsError>
Validates this constraints object against core invariants.
Sourcepub fn max_attempts(&self) -> u32
pub fn max_attempts(&self) -> u32
Returns the maximum number of attempts allowed for each run.
Sourcepub fn timeout_secs(&self) -> Option<u64>
pub fn timeout_secs(&self) -> Option<u64>
Returns the optional per-attempt timeout in seconds.
Sourcepub fn concurrency_key(&self) -> Option<&str>
pub fn concurrency_key(&self) -> Option<&str>
Returns the optional concurrency key.
Sourcepub fn set_max_attempts(
&mut self,
max_attempts: u32,
) -> Result<(), TaskConstraintsError>
pub fn set_max_attempts( &mut self, max_attempts: u32, ) -> Result<(), TaskConstraintsError>
Sets the attempt cap with invariant validation.
Sourcepub fn set_timeout_secs(
&mut self,
timeout_secs: Option<u64>,
) -> Result<(), TaskConstraintsError>
pub fn set_timeout_secs( &mut self, timeout_secs: Option<u64>, ) -> Result<(), TaskConstraintsError>
Sets the optional timeout in seconds.
§Errors
Returns TaskConstraintsError::ZeroTimeout if timeout_secs is Some(0).
Sourcepub fn set_concurrency_key(
&mut self,
concurrency_key: Option<String>,
) -> Result<(), TaskConstraintsError>
pub fn set_concurrency_key( &mut self, concurrency_key: Option<String>, ) -> Result<(), TaskConstraintsError>
Sets the optional concurrency key.
§Errors
Returns TaskConstraintsError::EmptyConcurrencyKey if the key is Some("").
Sourcepub fn concurrency_key_hold_policy(&self) -> ConcurrencyKeyHoldPolicy
pub fn concurrency_key_hold_policy(&self) -> ConcurrencyKeyHoldPolicy
Returns the concurrency key hold policy.
Sourcepub fn set_concurrency_key_hold_policy(
&mut self,
policy: ConcurrencyKeyHoldPolicy,
)
pub fn set_concurrency_key_hold_policy( &mut self, policy: ConcurrencyKeyHoldPolicy, )
Sets the concurrency key hold policy.
Sourcepub fn safety_level(&self) -> SafetyLevel
pub fn safety_level(&self) -> SafetyLevel
Returns the safety level classification for this task.
Sourcepub fn set_safety_level(&mut self, safety_level: SafetyLevel)
pub fn set_safety_level(&mut self, safety_level: SafetyLevel)
Sets the safety level classification.
Sourcepub fn required_capabilities(&self) -> Option<&[String]>
pub fn required_capabilities(&self) -> Option<&[String]>
Returns the required executor capabilities, if any.
In v0.x the local executor handles all tasks (this field is ignored). In Sprint 4 (v1.0), only remote actors declaring all listed capabilities will be offered this task.
Sourcepub fn with_capabilities(
self,
caps: Vec<String>,
) -> Result<Self, TaskConstraintsError>
pub fn with_capabilities( self, caps: Vec<String>, ) -> Result<Self, TaskConstraintsError>
Attaches required capabilities, returning the modified constraints.
The list must be non-empty; an empty vec is rejected at validation.
Trait Implementations§
Source§impl Clone for TaskConstraints
impl Clone for TaskConstraints
Source§fn clone(&self) -> TaskConstraints
fn clone(&self) -> TaskConstraints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more