Skip to main content

rskit_workload/
lib.rs

1//! Provider-based workload orchestration.
2//!
3//! `rskit-workload` mirrors gokit's `workload` package: a provider-agnostic
4//! [`Manager`] contract for deploying and managing workloads (containers, pods,
5//! or any long-running unit), an explicit backend [`WorkloadRegistry`], and a
6//! lifecycle-managed [`WorkloadComponent`] that plugs into the shared component
7//! registry.
8//!
9//! The crate is foundational: it owns the *concept and vocabulary* of workload
10//! orchestration. Concrete backends (Docker, Kubernetes, …) live in separate
11//! adapter crates and register a [`ManagerFactory`] into a [`WorkloadRegistry`];
12//! no backend is wired in implicitly.
13//!
14//! # Example
15//!
16//! ```rust
17//! use rskit_workload::{WorkloadComponent, WorkloadConfig};
18//! use rskit_component::Component;
19//!
20//! # #[tokio::main]
21//! # async fn main() -> rskit_errors::AppResult<()> {
22//! // Disabled config starts as a healthy no-op until a backend is registered.
23//! let component = WorkloadComponent::new(WorkloadConfig::default());
24//! component.start().await?;
25//! assert!(component.health().is_healthy());
26//! component.stop().await?;
27//! # Ok(())
28//! # }
29//! ```
30
31#![warn(missing_docs)]
32
33/// Lifecycle-managed workload component.
34pub mod component;
35/// Provider-agnostic workload configuration.
36pub mod config;
37/// Workload lifecycle manager and optional capability traits.
38pub mod manager;
39/// Explicit workload backend registry.
40pub mod registry;
41/// Runtime state and result reports.
42pub mod report;
43/// CPU and memory quantity parsing and formatting.
44pub mod resources;
45/// Deployment request and its nested specification types.
46pub mod spec;
47/// Workload runtime state and restart policy.
48pub mod state;
49
50#[cfg(test)]
51mod test_support;
52
53pub use component::WorkloadComponent;
54pub use config::WorkloadConfig;
55pub use manager::{
56    DiskUsageCapable, EventWatcher, ExecCapable, ImageEventWatcher, ImageInspector, LogStreamer,
57    Manager, StatsCapable, SystemInfoCapable,
58};
59pub use registry::{ManagerFactory, WorkloadRegistry};
60pub use report::{
61    DeployResult, DiskUsage, ExecResult, GpuInfo, ImageConfig, ImageDetail, ImageDiskEntry,
62    ImageEvent, SystemInfo, WaitResult, WorkloadEvent, WorkloadInfo, WorkloadStats, WorkloadStatus,
63};
64pub use resources::{format_cpu, format_memory, parse_cpu, parse_memory};
65pub use spec::{
66    DeployRequest, ImageEventFilter, ListFilter, LogOptions, NetworkConfig, PortMapping,
67    ResourceConfig, VolumeMount,
68};
69pub use state::{RestartPolicy, WorkloadState};