Documentation
¶
Index ¶
- type ConnPool
- type CpConn
- type GncpPool
- func (p *GncpPool) Close() error
- func (p *GncpPool) Get() (net.Conn, error)
- func (p *GncpPool) GetWithContext(ctx context.Context) (net.Conn, error)
- func (p *GncpPool) GetWithTimeout(timeout time.Duration) (net.Conn, error)
- func (p *GncpPool) Put(conn net.Conn) error
- func (p *GncpPool) Remove(conn net.Conn) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CpConn ¶
type GncpPool ¶
type GncpPool struct {
// contains filtered or unexported fields
}
GncpPool implements ConnPool interface. Use channel buffer connections.
func NewPool ¶
NewPool return new ConnPool. It base on channel. It will init minConn connections in channel first. When Get()/GetWithTimeout called, if channel still has connection it will get connection from channel. Otherwise GncpPool check number of connection which had already created as the number are less than maxConn, it use connCreator function to create new connection.
func (*GncpPool) Close ¶
Close close the connection pool. When close the connection pool it also close all connection already in connection pool. If connection not put back in connection it will not close. But it will close when it put back.
func (*GncpPool) Get ¶
Get get connection from connection pool. If connection poll is empty and alreay created connection number less than Max number of connection it will create new one. Otherwise it wil wait someone put connection back.
func (*GncpPool) GetWithContext ¶
func (*GncpPool) GetWithTimeout ¶
GetWithTimeout can let you get connection wait for a time duration. If cannot get connection in this time. It will return TimeOutError.