ftp_pool

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package ftp_pool implements a ftp pool based on "github.com/jlaffaye/ftp"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FTPPool

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

FTPPool is an ftp pool.

func NewFTPPool

func NewFTPPool(addr, user, passwd string, maxCachedConn, connLimit int) *FTPPool

NewFTPPool is the only way to get a new, ready-to-use FTPPool object.

addr: ftp address
user: ftp username
passwd: ftp password
maxCachedConn: Max pooled ftp connections
connLimit: Max ftp connections

Example:

ftpPool := NewFTPPool(Addr, User, Passwd, 10, 100)
ftpConn, _ := ftpPool.Get() // Gets an ftp connection from the pool, or creates a new one if the pool is empty
ftpPool.Put(ftpConn, false) // Puts an ftp connection back to the pool

func (*FTPPool) Addr

func (pool *FTPPool) Addr() string

func (*FTPPool) Get

func (pool *FTPPool) Get() (conn *ftp.ServerConn, err error)

Get gets an ftp connection from the pool. If no free connection is available and MaxConnLimit not reached, a new connection will be created. If MaxConnLimit is reached, Get blocks waiting to get/create a connection.

func (*FTPPool) MaxCachedConnNum

func (pool *FTPPool) MaxCachedConnNum() int

func (*FTPPool) Password

func (pool *FTPPool) Password() string

func (*FTPPool) Put

func (pool *FTPPool) Put(conn *ftp.ServerConn, forceFree bool)

Put returns an ftp connection to the pool. If MaxCachedConn had been reached, the connection will be discarded.

conn: ftp connection to be returned
forceFree: the connection will be discarded anyway if true is passed

func (*FTPPool) User

func (pool *FTPPool) User() string

Jump to

Keyboard shortcuts

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