Skip to main content

LifecycleHandle

Trait LifecycleHandle 

Source
pub trait LifecycleHandle: Send + Sync {
    // Required methods
    fn list(
        &self,
    ) -> impl Future<Output = Result<Vec<ResourceView>, LifecycleHandleError>> + Send;
    fn get(
        &self,
        name: &str,
    ) -> impl Future<Output = Result<ResourceView, LifecycleHandleError>> + Send;
    fn restart(
        &self,
        name: &str,
    ) -> impl Future<Output = Result<(), LifecycleHandleError>> + Send;
    fn logs(
        &self,
        name: &str,
        follow: bool,
    ) -> impl Future<Output = Result<LogChunkStream, LifecycleHandleError>> + Send;
    fn subscribe_events(&self) -> Receiver<LifecycleEvent>;
}
Expand description

Control-plane facing view of a running stack.

Implementations expose just enough to drive a dashboard, REST API, and CLI subcommands without leaking any backend type. The concrete implementation shipped with this crate is ManagerHandle.

Every async method returns LifecycleHandleError on failure.

Required Methods§

Source

fn list( &self, ) -> impl Future<Output = Result<Vec<ResourceView>, LifecycleHandleError>> + Send

Return a snapshot of every resource managed by this stack.

The returned ResourceView values are ordered by the topological plan order (dependencies before dependents).

Source

fn get( &self, name: &str, ) -> impl Future<Output = Result<ResourceView, LifecycleHandleError>> + Send

Look up a single resource by its manifest-declared name.

Returns LifecycleHandleError::UnknownResource when the name is not part of the current plan.

Source

fn restart( &self, name: &str, ) -> impl Future<Output = Result<(), LifecycleHandleError>> + Send

Restart a single resource by its manifest-declared name.

Delegates to crate::LifecycleManager::restart_one. Dependents keep running. Returns LifecycleHandleError::UnknownResource when the name is not part of the current plan.

Source

fn logs( &self, name: &str, follow: bool, ) -> impl Future<Output = Result<LogChunkStream, LifecycleHandleError>> + Send

Stream logs for a single resource by its manifest-declared name.

When follow is true the stream stays open and emits new chunks as they arrive; when false the stream completes after existing logs are drained. Returns LifecycleHandleError::UnknownResource when the name is not part of the plan, or a LifecycleHandleError::Runtime variant when the container is not yet running.

Source

fn subscribe_events(&self) -> Receiver<LifecycleEvent>

Open a fresh subscription on the lifecycle event broadcast channel.

Multiple consumers (REST handlers, WebSocket sessions, CLI progress bars) can hold independent receivers. A receiver that falls more than the channel capacity behind will observe a RecvError::Lagged and must resynchronise by calling LifecycleHandle::list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§