pub trait WorkloadKind: Send + Sync {
// Required methods
fn id(&self) -> &'static str;
fn validate(&self, envelope: &ManifestEnvelope) -> Result<(), ManifestError>;
fn load(
&self,
package_dir: &Path,
anchors: &TrustAnchors,
kinds: &KindRegistry,
) -> Result<VerifiedWorkload, PlaneError>;
fn spec(&self, workload: &VerifiedWorkload) -> Result<WorkloadSpec, String>;
fn adapters(&self) -> &'static [&'static str];
// Provided methods
fn health(&self) -> HealthSpec { ... }
fn judge(&self, sample: &HealthSample) -> Health { ... }
fn migratable(&self) -> bool { ... }
}Expand description
What a workload kind contributes to validation and placement.
Required Methods§
Sourcefn validate(&self, envelope: &ManifestEnvelope) -> Result<(), ManifestError>
fn validate(&self, envelope: &ManifestEnvelope) -> Result<(), ManifestError>
Validate the envelope’s kind-specific body (shape and limits; not signatures or file contents, which are kind-agnostic).
Sourcefn load(
&self,
package_dir: &Path,
anchors: &TrustAnchors,
kinds: &KindRegistry,
) -> Result<VerifiedWorkload, PlaneError>
fn load( &self, package_dir: &Path, anchors: &TrustAnchors, kinds: &KindRegistry, ) -> Result<VerifiedWorkload, PlaneError>
Verify the signed package in package_dir against anchors (with
kinds as the registry the manifest is checked against) and load it
as a runnable workload. Must refuse a manifest whose kind is not
id.
Sourcefn spec(&self, workload: &VerifiedWorkload) -> Result<WorkloadSpec, String>
fn spec(&self, workload: &VerifiedWorkload) -> Result<WorkloadSpec, String>
The placement requirements for a loaded workload of this kind.
Provided Methods§
Sourcefn health(&self) -> HealthSpec
fn health(&self) -> HealthSpec
How often instances of this kind are polled and how many bad polls in a row make one unhealthy (ADR-099 section 7).
Sourcefn judge(&self, sample: &HealthSample) -> Health
fn judge(&self, sample: &HealthSample) -> Health
Judge one poll of an instance of this kind. The default is the
process-backed judgment (judge_process).
Sourcefn migratable(&self) -> bool
fn migratable(&self) -> bool
Whether the placer may move an instance of this kind to another
node when its node is lost. A kind with state that cannot move (warm
inference caches, hardware-bound work) says false: the loss is
raised as an alert instead of being rescheduled.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".