sshpool

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDefault

func CloseDefault() error

CloseDefault closes the default pool.

Types

type Config

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	KeyFile  string
	Timeout  time.Duration
}

Config holds SSH connection configuration.

type Option

type Option func(*Pool)

Option configures the Pool.

func WithIdleTimeout

func WithIdleTimeout(d time.Duration) Option

WithIdleTimeout sets the idle timeout for connections.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool manages a pool of SSH connections.

func Default

func Default() *Pool

Default returns the default global pool.

func New

func New(opts ...Option) *Pool

New creates a new connection pool.

func (*Pool) Close

func (p *Pool) Close() error

Close closes all connections and stops the cleaner.

func (*Pool) Get

func (p *Pool) Get(ctx context.Context, cfg *Config) (*ssh.Client, error)

Get returns an SSH client for the given configuration. If a connection exists and is healthy, it will be reused.

func (*Pool) Stats

func (p *Pool) Stats() (active int, idle int)

Stats returns pool statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL