pub struct LifecyclePlan { /* private fields */ }Expand description
Topologically sorted execution plan.
Built by LifecyclePlan::from_manifest and consumed by
crate::LifecycleManager. The node order guarantees that every resource
appears after all of its direct and transitive dependencies.
§Example
use lightshuttle_manifest::Manifest;
use lightshuttle_runtime::LifecyclePlan;
let yaml = r#"
project:
name: myapp
resources:
db:
postgres:
version: "16"
api:
container:
image: myapp:latest
depends_on: [db]
"#;
let manifest = Manifest::parse(yaml).expect("valid manifest");
let plan = LifecyclePlan::from_manifest(&manifest)?;
// Nodes are sorted: "db" appears before "api".
for node in plan.nodes() {
println!("{} ({}) -> {:?}", node.name, node.kind, node.depends_on);
}Implementations§
Source§impl LifecyclePlan
impl LifecyclePlan
Sourcepub fn env_report(&self, extra_env: &HashMap<String, String>) -> EnvReport
pub fn env_report(&self, extra_env: &HashMap<String, String>) -> EnvReport
Classify every ${env.*} reference in this plan against the ambient
process environment plus extra_env (which takes precedence).
Only environment values and command arguments are scanned because those are the only sites the runtime interpolates at start time. References in image tags or working directories are intentionally excluded.
The resolution logic delegates to the same Interpolator the runtime
uses, so an empty value counts as unset and the report mirrors what a
real start_all call would do. This makes the report suitable as both a
preflight check (called by crate::LifecycleManager::check_required_env)
and a diagnostic tool (called by lightshuttle secrets check).
The extra_env argument carries the contents of the loaded .env file.
Entries in extra_env with an empty string value are treated as unset.
Source§impl LifecyclePlan
impl LifecyclePlan
Sourcepub fn from_manifest(manifest: &Manifest) -> Result<Self, LifecycleError>
pub fn from_manifest(manifest: &Manifest) -> Result<Self, LifecycleError>
Build a plan from a parsed manifest.
Resolves the dependency graph, performs a topological sort (Kahn’s
algorithm) and converts every resource to a ContainerSpec.
§Errors
Returns crate::LifecycleError::Cycle when the dependency graph
contains a cycle, crate::LifecycleError::ResourceNotFound when a
resource references an unknown dependency, and
crate::LifecycleError::SpecBuild when a resource cannot be
converted to a ContainerSpec.
Sourcepub fn nodes(&self) -> &[PlanNode]
pub fn nodes(&self) -> &[PlanNode]
Returns the nodes in topological order.
A node is guaranteed to appear after every node it depends on.
The crate::LifecycleManager iterates this slice to start resources
in order, spawning independent branches concurrently.
Sourcepub fn dependents_of(&self, name: &str) -> Vec<&str>
pub fn dependents_of(&self, name: &str) -> Vec<&str>
Returns the names of resources that directly depend on name,
sorted alphabetically.
Used during teardown to determine which downstream resources must be stopped before their dependency can be removed.
Trait Implementations§
Source§impl Clone for LifecyclePlan
impl Clone for LifecyclePlan
Source§fn clone(&self) -> LifecyclePlan
fn clone(&self) -> LifecyclePlan
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LifecyclePlan
impl RefUnwindSafe for LifecyclePlan
impl Send for LifecyclePlan
impl Sync for LifecyclePlan
impl Unpin for LifecyclePlan
impl UnsafeUnpin for LifecyclePlan
impl UnwindSafe for LifecyclePlan
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request