pub struct SshClient { /* private fields */ }Expand description
SSH client for a single worker connection.
Implementations§
Source§impl SshClient
impl SshClient
Sourcepub fn new(config: WorkerConfig, options: SshOptions) -> Self
pub fn new(config: WorkerConfig, options: SshOptions) -> Self
Create a new SSH client for a worker.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected to the worker.
Sourcepub async fn disconnect(&mut self) -> Result<()>
pub async fn disconnect(&mut self) -> Result<()>
Disconnect from the worker.
Sourcepub async fn reconnect(&mut self) -> Result<()>
pub async fn reconnect(&mut self) -> Result<()>
Force a fresh connection, dropping any existing (possibly dead) session.
connect is a no-op when a Session object already
exists, so a pooled client whose underlying SSH ControlMaster has died
cannot recover through it. reconnect tears the stale session down first
(closing it best-effort — a dead master may itself error on close, but
disconnect take()s the session before closing so
it is gone regardless) and then establishes a new one.
Sourcepub async fn execute(&self, command: &str) -> Result<CommandResult>
pub async fn execute(&self, command: &str) -> Result<CommandResult>
Execute a command on the remote worker using this client’s configured command timeout.
Sourcepub async fn execute_with_timeout(
&self,
command: &str,
command_timeout: Duration,
) -> Result<CommandResult>
pub async fn execute_with_timeout( &self, command: &str, command_timeout: Duration, ) -> Result<CommandResult>
Execute a command on the remote worker with an explicit per-call timeout.
Used by the connection pool (SshPool::run_with_timeout) so a single
pooled client can serve calls with different timeouts (a fast health
probe vs. a slower cleanup) without mutating the shared client options.
Sourcepub async fn execute_streaming<F, G>(
&self,
command: &str,
on_stdout: F,
on_stderr: G,
) -> Result<CommandResult>
pub async fn execute_streaming<F, G>( &self, command: &str, on_stdout: F, on_stderr: G, ) -> Result<CommandResult>
Execute a command and stream output in real-time.
Sourcepub async fn health_check(&self) -> Result<bool>
pub async fn health_check(&self) -> Result<bool>
Check if the worker is reachable via SSH.
Sourcepub async fn health_check_with_timeout(&self, timeout: Duration) -> Result<bool>
pub async fn health_check_with_timeout(&self, timeout: Duration) -> Result<bool>
health_check bounded by timeout instead of
the client’s command timeout (300s for pooled clients).