pub struct TaskSpecBuilder { /* private fields */ }Expand description
Builder for TaskSpec.
Required fields are set by TaskSpec::builder.
Optional fields use these defaults:
backoff:BackoffPolicy::default(full jitter, 1 second to 30 seconds, factor 2)admission:AdmissionPolicy::DropIfRunningrestart:RestartPolicy::Nevermax_retries:Nonerunner_selector:None
§Example
use solti_model::{AdmissionPolicy, EmbeddedSpec, RestartPolicy, TaskSpec, TaskWorkload};
let workload = TaskWorkload::Embedded(EmbeddedSpec::new("v1").unwrap());
let spec = TaskSpec::builder("service", workload, 5_000u64)
.restart(RestartPolicy::always())
.admission(AdmissionPolicy::Replace)
.build()
.unwrap();
assert_eq!(spec.restart(), RestartPolicy::always());
assert_eq!(spec.admission(), AdmissionPolicy::Replace);Implementations§
Source§impl TaskSpecBuilder
impl TaskSpecBuilder
Sourcepub fn restart(self, restart: RestartPolicy) -> Self
pub fn restart(self, restart: RestartPolicy) -> Self
Sets the restart policy.
Sourcepub fn max_retries(self, max_retries: impl Into<Option<NonZeroU32>>) -> Self
pub fn max_retries(self, max_retries: impl Into<Option<NonZeroU32>>) -> Self
Sets the failure-retry budget.
None means unlimited.
let workload = TaskWorkload::Embedded(EmbeddedSpec::new("v1").unwrap());
let spec = TaskSpec::builder("s", workload, 1_000u64)
.max_retries(NonZeroU32::new(3))
.build()
.expect("valid spec");
assert_eq!(spec.max_retries().map(NonZeroU32::get), Some(3));Sourcepub fn backoff(self, backoff: BackoffPolicy) -> Self
pub fn backoff(self, backoff: BackoffPolicy) -> Self
Sets the backoff policy.
Sourcepub fn admission(self, admission: AdmissionPolicy) -> Self
pub fn admission(self, admission: AdmissionPolicy) -> Self
Sets the admission policy.
Sourcepub fn runner_selector(self, sel: LabelSelector) -> Self
pub fn runner_selector(self, sel: LabelSelector) -> Self
Sets the runner selector.
Sourcepub fn build(self) -> ModelResult<TaskSpec>
pub fn build(self) -> ModelResult<TaskSpec>
Builds and validates the spec.
Runner availability is not checked by this crate.
§Errors
Returns ModelError::Invalid when any structural field is invalid.
§Example
use solti_model::{EmbeddedSpec, TaskSpec, TaskWorkload};
let workload = TaskWorkload::Embedded(EmbeddedSpec::new("v1").unwrap());
let err = TaskSpec::builder("", workload, 1_000u64)
.build()
.unwrap_err();
assert!(err.to_string().contains("slot"));Auto Trait Implementations§
impl Freeze for TaskSpecBuilder
impl RefUnwindSafe for TaskSpecBuilder
impl Send for TaskSpecBuilder
impl Sync for TaskSpecBuilder
impl Unpin for TaskSpecBuilder
impl UnsafeUnpin for TaskSpecBuilder
impl UnwindSafe for TaskSpecBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more