Skip to main content

WorkloadKind

Trait WorkloadKind 

Source
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§

Source

fn id(&self) -> &'static str

The manifest kind string this implementation handles.

Source

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).

Source

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.

Source

fn spec(&self, workload: &VerifiedWorkload) -> Result<WorkloadSpec, String>

The placement requirements for a loaded workload of this kind.

Source

fn adapters(&self) -> &'static [&'static str]

Adapter route names that can run this kind (native, container, emulated, remote.api, …).

Provided Methods§

Source

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).

Source

fn judge(&self, sample: &HealthSample) -> Health

Judge one poll of an instance of this kind. The default is the process-backed judgment (judge_process).

Source

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".

Implementors§