Skip to main content

SshPool

Struct SshPool 

Source
pub struct SshPool { /* private fields */ }
Expand description

Connection pool for managing multiple SSH connections.

Implementations§

Source§

impl SshPool

Source

pub fn new(options: SshOptions) -> Self

Create a new connection pool.

Source

pub async fn get_or_connect( &self, config: &WorkerConfig, ) -> Result<Arc<RwLock<SshClient>>>

Get or create a connection to a worker.

Validates liveness on borrow: a pooled SshClient reports is_connected purely from the presence of a Session object, which cannot detect that the underlying SSH ControlMaster has died (idle ControlPersist expiry, a network blip, or the remote sshd being restarted). Returning such a client hands the caller a dead master, and its next execute() fails with broken-pipe/connection-closed and no chance to recover. So before reusing a connected client this probes it with a lightweight health check, and on failure reconnects once under the per-worker write lock.

Source

pub async fn close(&self, worker_id: &WorkerId) -> Result<()>

Close a specific connection.

Source

pub async fn close_all(&self) -> Result<()>

Close all connections.

Source

pub async fn active_connections(&self) -> usize

Get the number of active connections.

Source

pub async fn run_with_timeout( &self, config: &WorkerConfig, command: &str, command_timeout: Duration, ) -> Result<CommandResult>

Run a single command on a worker over a POOLED (warm, reused) connection, bounded by command_timeout.

This is the entry point daemon subsystems use instead of the throwaway SshClient::new().connect()...execute()...disconnect() dance. It get_or_connects a live master (validating liveness on borrow and reconnecting a dead one), runs exactly one command, and — crucially — does NOT disconnect afterwards, keeping the ControlMaster warm for the next call. That is the whole point: reuse one master per worker instead of spawning (and, under the old code, leaking) a fresh master for every telemetry/health/cleanup poll.

The per-command timeout is applied via a temporary SshOptions override on the pooled client so it does not disturb the pool’s shared default (e.g. a long build vs. a short health probe). The connect timeout and control-master/persist settings come from the pool’s options — except that Windows workers are ALWAYS non-mux (see [pooled_client_options]): Windows OpenSSH cannot multiplex, so a pooled mux session hangs at the command stage.

Trait Implementations§

Source§

impl Default for SshPool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more