pub struct RuntimeOutputs { /* private fields */ }Expand description
Runtime outputs generated during deployment operations
This struct contains fields that are generated during deployment operations and represent the runtime state of deployed infrastructure. Fields are private to protect invariants and provide semantic clarity through setters.
§Lifecycle
Fields are populated at different stages of the deployment lifecycle:
- Creation: All fields are
None(useRuntimeOutputs::new()) - After Provisioning:
instance_ipandprovision_methodare set (userecord_provisioning()orrecord_registration()) - After Run Command:
service_endpointsis set (userecord_services_started())
§Future Fields
This struct is expected to grow as deployment operations become more complex:
container_id: Option<String>- Container/VM identifierresource_metrics: Option<ResourceMetrics>- CPU, memory, disk usage
§Examples
use torrust_tracker_deployer_lib::domain::environment::runtime_outputs::{RuntimeOutputs, ProvisionMethod};
use std::net::{IpAddr, Ipv4Addr};
// Create empty runtime outputs
let mut runtime_outputs = RuntimeOutputs::new();
assert!(runtime_outputs.instance_ip().is_none());
// After provisioning, record the IP and method
let ip = IpAddr::V4(Ipv4Addr::new(192, 168, 1, 100));
runtime_outputs.record_provisioning(ip);
assert_eq!(runtime_outputs.instance_ip(), Some(ip));
assert_eq!(runtime_outputs.provision_method(), Some(ProvisionMethod::Provisioned));Implementations§
Source§impl RuntimeOutputs
impl RuntimeOutputs
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates new empty runtime outputs
All fields are initialized to None, representing an environment
that has not yet been provisioned or run.
§Examples
use torrust_tracker_deployer_lib::domain::environment::runtime_outputs::RuntimeOutputs;
let outputs = RuntimeOutputs::new();
assert!(outputs.instance_ip().is_none());
assert!(outputs.provision_method().is_none());
assert!(outputs.service_endpoints().is_none());Sourcepub fn instance_ip(&self) -> Option<IpAddr>
pub fn instance_ip(&self) -> Option<IpAddr>
Returns the instance IP address if available
This is None until the environment has been provisioned or registered.
Sourcepub fn provision_method(&self) -> Option<ProvisionMethod>
pub fn provision_method(&self) -> Option<ProvisionMethod>
Returns how the instance was provisioned
None: Unknown or legacy stateSome(Provisioned): Created viaprovisioncommandSome(Registered): Connected viaregistercommand
Sourcepub fn service_endpoints(&self) -> Option<&ServiceEndpoints>
pub fn service_endpoints(&self) -> Option<&ServiceEndpoints>
Returns the service endpoints if available
This is None until the run command has started services successfully.
Sourcepub fn record_provisioning(&mut self, ip: IpAddr)
pub fn record_provisioning(&mut self, ip: IpAddr)
Records that provisioning has completed with the given instance IP
Call this after the provision command successfully creates infrastructure.
Sets both instance_ip and provision_method to Provisioned.
§Arguments
ip- The IP address of the newly provisioned instance
Sourcepub fn record_registration(&mut self, ip: IpAddr)
pub fn record_registration(&mut self, ip: IpAddr)
Records that an existing instance has been registered
Call this after the register command connects to existing infrastructure.
Sets both instance_ip and provision_method to Registered.
§Arguments
ip- The IP address of the registered instance
Sourcepub fn record_services_started(&mut self, endpoints: ServiceEndpoints)
pub fn record_services_started(&mut self, endpoints: ServiceEndpoints)
Records that services have been started with the given endpoints
Call this after the run command successfully starts all services.
The endpoints can then be displayed to users or used for health checks.
§Arguments
endpoints- The URLs for all running services
Sourcepub fn set_instance_ip(&mut self, ip: IpAddr)
pub fn set_instance_ip(&mut self, ip: IpAddr)
Sets the instance IP directly
Prefer record_provisioning() or record_registration() which also
set the provision method. This method is provided for cases where
only the IP needs to be updated (e.g., deserialization workarounds).
Sourcepub fn set_provision_method(&mut self, method: ProvisionMethod)
pub fn set_provision_method(&mut self, method: ProvisionMethod)
Sets the provision method directly
Prefer record_provisioning() or record_registration() which also
set the instance IP. This method is provided for backward compatibility.
Trait Implementations§
Source§impl Clone for RuntimeOutputs
impl Clone for RuntimeOutputs
Source§impl Debug for RuntimeOutputs
impl Debug for RuntimeOutputs
Source§impl Default for RuntimeOutputs
impl Default for RuntimeOutputs
Source§impl<'de> Deserialize<'de> for RuntimeOutputs
impl<'de> Deserialize<'de> for RuntimeOutputs
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RuntimeOutputs
impl RefUnwindSafe for RuntimeOutputs
impl Send for RuntimeOutputs
impl Sync for RuntimeOutputs
impl Unpin for RuntimeOutputs
impl UnsafeUnpin for RuntimeOutputs
impl UnwindSafe for RuntimeOutputs
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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