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

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