#[non_exhaustive]pub enum TaskWorkload {
Subprocess(SubprocessSpec),
Wasm(WasmSpec),
Container(ContainerSpec),
Embedded(EmbeddedSpec),
Extension(ExtensionWorkload),
}Expand description
Executable desired state nested in a TaskSpec.
| Variant | Backend | Routable |
|---|---|---|
Subprocess | OS process (command, args) | yes |
Container | OCI container image | yes |
Embedded | In-process implementation | no |
Wasm | WASI module (.wasm) | yes |
Extension | Application-provided runner | yes |
Routable variants are selected by solti-runner.
Embedded carries no runtime task handle.
§Example
use solti_model::{Flag, SubprocessMode, SubprocessSpec, TaskEnv, TaskWorkload};
let workload = TaskWorkload::Subprocess(SubprocessSpec::new(
SubprocessMode::Command {
command: "echo".into(),
args: vec!["hello".into()],
},
TaskEnv::default(),
None,
Flag::enabled(),
));
assert_eq!(workload.kind(), "Subprocess");
workload.validate().unwrap();Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Subprocess(SubprocessSpec)
Execute a subprocess on the host.
Wasm(WasmSpec)
Execute a WebAssembly module via a WASI-compatible runtime.
Container(ContainerSpec)
Run a task inside an OCI-compatible container.
Embedded(EmbeddedSpec)
Code-defined task that bypasses runner routing.
A higher layer binds the desired revision to an in-process task.
Extension(ExtensionWorkload)
Workload implemented by an application-provided runner.
Implementations§
Source§impl TaskWorkload
impl TaskWorkload
Sourcepub fn api_version(&self) -> &str
pub fn api_version(&self) -> &str
Returns the workload API group and version.
Sourcepub fn type_meta(&self) -> WorkloadTypeMeta
pub fn type_meta(&self) -> WorkloadTypeMeta
Returns owned workload type metadata.
Sourcepub fn kind(&self) -> &str
pub fn kind(&self) -> &str
Returns the workload resource kind.
§Example
use solti_model::TaskWorkload;
let embedded = TaskWorkload::Embedded(solti_model::EmbeddedSpec::new("v1").unwrap());
assert_eq!(embedded.kind(), "Embedded");Sourcepub fn validate(&self) -> ModelResult<()>
pub fn validate(&self) -> ModelResult<()>
Validates kind-specific constraints.
Delegates to the inner workload spec.
Embedded requires a non-empty implementation revision.
§Errors
Returns ModelError::Invalid when the selected spec is invalid.
§Example
use solti_model::{ContainerSpec, TaskEnv, TaskWorkload};
let workload = TaskWorkload::Container(ContainerSpec::new(
"redis:7".into(),
None,
vec![],
TaskEnv::default(),
));
workload.validate().unwrap();Trait Implementations§
Source§impl Clone for TaskWorkload
impl Clone for TaskWorkload
Source§fn clone(&self) -> TaskWorkload
fn clone(&self) -> TaskWorkload
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TaskWorkload
impl Debug for TaskWorkload
Source§impl<'de> Deserialize<'de> for TaskWorkload
impl<'de> Deserialize<'de> for TaskWorkload
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TaskWorkload
Source§impl JsonSchema for TaskWorkload
Available on crate feature schema only.
impl JsonSchema for TaskWorkload
Available on crate feature
schema only.Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for TaskWorkload
impl PartialEq for TaskWorkload
Source§impl Serialize for TaskWorkload
impl Serialize for TaskWorkload
impl StructuralPartialEq for TaskWorkload
Auto Trait Implementations§
impl Freeze for TaskWorkload
impl RefUnwindSafe for TaskWorkload
impl Send for TaskWorkload
impl Sync for TaskWorkload
impl Unpin for TaskWorkload
impl UnsafeUnpin for TaskWorkload
impl UnwindSafe for TaskWorkload
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