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 ¶
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) 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 (*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
Click to show internal directories.
Click to hide internal directories.