pub struct RegisterCommandHandler { /* private fields */ }Expand description
RegisterCommandHandler registers existing instances with environments
This command handler provides an alternative path to ProvisionCommandHandler.
Instead of provisioning new infrastructure, it registers an existing instance
(VM, physical server, or container) with an environment.
§State Management
The command handler integrates with the type-state pattern for environment lifecycle:
- Accepts
Environment<Created>as input - Returns
Environment<Provisioned>on success
This allows the environment to continue with configure, release, and run
commands just like a normally provisioned environment.
§Workflow
- Load environment from repository (must be in Created state)
- Validate SSH connectivity to the provided IP address
- Render Ansible templates with the instance IP
- Update runtime outputs with the instance IP and provision method
- Transition to Provisioned state
- Persist the updated environment
Implementations§
Source§impl RegisterCommandHandler
impl RegisterCommandHandler
Sourcepub fn new(
clock: Arc<dyn Clock>,
repository: Arc<dyn EnvironmentRepository>,
) -> Self
pub fn new( clock: Arc<dyn Clock>, repository: Arc<dyn EnvironmentRepository>, ) -> Self
Create a new RegisterCommandHandler
Sourcepub async fn execute(
&self,
env_name: &EnvironmentName,
instance_ip: IpAddr,
ssh_port: Option<u16>,
) -> Result<Environment<Provisioned>, RegisterCommandHandlerError>
pub async fn execute( &self, env_name: &EnvironmentName, instance_ip: IpAddr, ssh_port: Option<u16>, ) -> Result<Environment<Provisioned>, RegisterCommandHandlerError>
Execute the register workflow
§Arguments
env_name- The name of the environment to register the instance withinstance_ip- The IP address of the existing instancessh_port- Optional SSH port (overrides environment config if provided)
§Returns
Returns the environment in Provisioned state
§Errors
Returns an error if:
- Environment not found or not in
Createdstate - SSH connectivity validation fails
- Ansible template rendering fails
- Unable to persist the environment state
Auto Trait Implementations§
impl !RefUnwindSafe for RegisterCommandHandler
impl !Send for RegisterCommandHandler
impl !Sync for RegisterCommandHandler
impl !UnwindSafe for RegisterCommandHandler
impl Freeze for RegisterCommandHandler
impl Unpin for RegisterCommandHandler
impl UnsafeUnpin for RegisterCommandHandler
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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>
Wrap the input message
T in a tonic::Request