Expand description
Environment State Marker Types
This module defines the state marker types used in the type-state pattern for the Environment entity. Each state represents a distinct phase in the deployment lifecycle and is enforced at compile-time.
§Type-State Pattern
The type-state pattern uses Rust’s type system to enforce state machine
transitions at compile-time. Each state is a distinct type, and the
Environment<S> struct is generic over the state type. This ensures that
invalid state transitions are caught during compilation rather than at runtime.
§State Lifecycle
§Happy Path
Created → Provisioning → Provisioned → Configuring → Configured
→ Releasing → Released → Running → Destroyed§Error States
At each operational phase, the system can transition to a corresponding failed state if an error occurs:
Provisioning→ProvisionFailedConfiguring→ConfigureFailedReleasing→ReleaseFailedRunning→RunFailed
§Usage Example
use torrust_tracker_deployer_lib::domain::environment::state::{Created, Provisioning};
// State types are used as type parameters for Environment<S>
// let env: Environment<Created> = Environment::new(name, credentials);
// let env: Environment<Provisioning> = env.start_provisioning();Structs§
- Base
Failure Context - Base failure context shared across all command failures
- Configure
Failed - Error state - Application configuration failed
- Configure
Failure Context - Error context for configure command failures
- Configured
- Final state - Application configuration completed successfully
- Configuring
- Intermediate state - Application configuration in progress
- Created
- Initial state - Environment has been created but no operations performed
- Destroy
Failed - Error state - Infrastructure destruction failed
- Destroy
Failure Context - Error context for destroy command failures
- Destroyed
- Terminal state - Environment has been destroyed
- Destroying
- Intermediate state - Infrastructure destruction in progress
- Provision
Failed - Error state - Infrastructure provisioning failed
- Provision
Failure Context - Error context for provision command failures
- Provisioned
- Final state - Infrastructure provisioning completed successfully
- Provisioning
- Intermediate state - Infrastructure provisioning in progress
- Release
Failed - Error state - Release preparation failed
- Release
Failure Context - Structured failure context for release command errors
- Released
- Final state - Release preparation completed successfully
- Releasing
- Intermediate state - Release preparation in progress
- RunFailed
- Error state - Application runtime failed
- RunFailure
Context - Structured failure context for run command errors
- Running
- Final state - Application is running
Enums§
- AnyEnvironment
State - Type-erased environment that can hold any typed
Environment<S>at runtime - Configure
Step - Steps in the configure workflow
- Destroy
Step - Steps in the destroy workflow
- Provision
Step - Steps in the provision workflow
- Release
Step - Steps in the release workflow
- RunStep
- Steps in the run workflow
- State
Type Error - Error type for invalid type conversions when working with type-erased environments