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