Skip to content

Commit 648d052

Browse files
committed
refactor: organize SSH Connection methods into logical groups
- Add clear section headers for different method responsibilities - Group CONNECTION LIFECYCLE METHODS (connection management) - Group HEALTH MONITORING METHODS (connection validation) - Group AUTHENTICATION METHODS (password and key-based auth) - Group COMMAND EXECUTION METHODS (execution orchestration) - Group CHANNEL OPERATIONS (SSH channel I/O operations) - Group UTILITY METHODS (helpers and cleanup) This organization makes the code structure clearer and identifies natural boundaries for future refactoring, particularly the Channel Operations group which could be extracted into a separate wrapper.
1 parent 7750eb2 commit 648d052

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/TorrustDeploy/Infrastructure/SSH/Connection.pm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ has '_last_health_check' => (
7777
is => 'rw',
7878
);
7979

80+
#==============================================================================
81+
# CONNECTION LIFECYCLE METHODS
82+
# Methods that manage the SSH2 connection state and lifecycle
83+
#==============================================================================
84+
8085
sub _build__ssh2 {
8186
my ($self) = @_;
8287

@@ -96,6 +101,11 @@ sub _build__ssh2 {
96101
return $ssh2;
97102
}
98103

104+
#==============================================================================
105+
# HEALTH MONITORING METHODS
106+
# Methods that check and validate connection health
107+
#==============================================================================
108+
99109
# Connection health and validation methods
100110
sub _is_connection_expired {
101111
my ($self) = @_;
@@ -196,6 +206,11 @@ sub _read_health_check_output {
196206
return $output;
197207
}
198208

209+
#==============================================================================
210+
# AUTHENTICATION METHODS
211+
# Methods that handle SSH authentication (password and key-based)
212+
#==============================================================================
213+
199214
sub test_password_connection {
200215
my ($self) = @_;
201216

@@ -246,6 +261,11 @@ sub test_key_connection {
246261
return $result;
247262
}
248263

264+
#==============================================================================
265+
# COMMAND EXECUTION METHODS
266+
# Methods that handle command execution orchestration and retry logic
267+
#==============================================================================
268+
249269
sub execute_command {
250270
my ($self, $command) = @_;
251271

@@ -302,6 +322,11 @@ sub _execute_single_command {
302322
};
303323
}
304324

325+
#==============================================================================
326+
# CHANNEL OPERATIONS
327+
# Methods that work directly with SSH channels for I/O operations
328+
#==============================================================================
329+
305330
sub _create_command_channel {
306331
my ($self, $ssh2, $command) = @_;
307332

@@ -350,6 +375,11 @@ sub _create_failure_result {
350375
};
351376
}
352377

378+
#==============================================================================
379+
# UTILITY METHODS
380+
# Helper methods and cleanup functions
381+
#==============================================================================
382+
353383
sub execute_command_with_sudo {
354384
my ($self, $command) = @_;
355385

0 commit comments

Comments
 (0)