Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePool(remote string) (net.Conn, error)
- func GetSysMax() int32
- func NetConn(p *Pool) net.Conn
- func Wrapper(p *Pool) io.ReadWriteCloser
- type ConnNode
- func (cn *ConnNode) After(n *ConnNode)
- func (cn *ConnNode) Before(n *ConnNode)
- func (cn *ConnNode) Down() bool
- func (cn *ConnNode) IsAvailable() bool
- func (cn *ConnNode) IsBusy() bool
- func (cn *ConnNode) IsClosed() bool
- func (cn *ConnNode) IsDown() bool
- func (cn *ConnNode) MoveTo(next *ConnNode, prev *ConnNode)
- func (cn *ConnNode) Up() bool
- func (cn *ConnNode) Wait()
- type Opts
- type Pool
- func (p *Pool) AddConn(cn *ConnNode)
- func (p *Pool) Close()
- func (p *Pool) EpollClose()
- func (p *Pool) Get() (*ConnNode, error)
- func (p *Pool) GetReadableConn() (net.Conn, error)
- func (p *Pool) MoveToHead(cp *ConnNode)
- func (p *Pool) MoveToTail(cp *ConnNode)
- func (p *Pool) Push(c net.Conn) *ConnNode
- func (p *Pool) Put(c *ConnNode)
- func (p *Pool) Read(b []byte) (n int, err error)
- func (p *Pool) Reconnect(cn *ConnNode)
- func (p *Pool) Remote() string
- func (p *Pool) Remove(n *ConnNode)
- func (p *Pool) RemoveConn(cn *ConnNode)
- func (p *Pool) ReplaceRemote(remote string) error
- func (p *Pool) SetDialContext(ctx context.Context)
- func (p *Pool) SetDialer(d *net.Dialer)
- func (p *Pool) SetMaxConn(max int32)
- func (p *Pool) SetMinConn(min int32) error
- func (p *Pool) SetRemote(remote string)
- type PoolNetconn
- func (p *PoolNetconn) Close() error
- func (p *PoolNetconn) LocalAddr() net.Addr
- func (p *PoolNetconn) Read(b []byte) (n int, err error)
- func (p *PoolNetconn) ReadFrom(r io.Reader) (n int64, err error)
- func (p *PoolNetconn) RemoteAddr() net.Addr
- func (p *PoolNetconn) SetDeadline(t time.Time) error
- func (p *PoolNetconn) SetReadDeadline(t time.Time) error
- func (p *PoolNetconn) SetWriteDeadline(t time.Time) error
- func (p *PoolNetconn) Write(b []byte) (n int, err error)
- func (p *PoolNetconn) WriteTo(w io.Writer) (n int64, err error)
- type PoolWrapper
Constants ¶
View Source
const ( UP int32 = iota DOWN )
View Source
const ( MIN_SIZE = 8 EPOLL_MAX_SIZE = 1024 MIN_READABLE_QUEUE_SIZE = 1024 ATTEMPT_RECONNECT = 100 RECONNECT_TIMEOUT = 300 // it seems that the value of syscall.EPOLLET is wrong EPOLLET = 0x80000000 )
Variables ¶
View Source
var ( NO_AVAILABLE_CONN = errors.New("no available connections!") POOL_CLOSED = errors.New("pool has been closed") )
Functions ¶
func Wrapper ¶
func Wrapper(p *Pool) io.ReadWriteCloser
Types ¶
type ConnNode ¶
func (*ConnNode) IsAvailable ¶ added in v2.0.3
connection is available or not
type Opts ¶
type Opts []interface{}
func DefaultOpts ¶
func DefaultOpts() Opts
func (Opts) WithContext ¶
func (Opts) WithDialer ¶
func (Opts) WithMinSize ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) AddConn ¶ added in v2.0.2
this is NOT A THREAD-SAFE method please check the Reconnect/Push function for the correct usage.
func (*Pool) EpollClose ¶
func (p *Pool) EpollClose()
func (*Pool) RemoveConn ¶ added in v2.0.2
this is NOT A THREAD-SAFE method please check the Reconnect/Push function for the correct usage. before calling this, you MUST lock the mutex lock of ConnNode. otherwise, it will cause the data race problem. if this connection is in used, removing this will cause nil pointer panic.
func (*Pool) ReplaceRemote ¶ added in v2.0.2
func (*Pool) SetDialContext ¶ added in v2.0.2
set new dial context
func (*Pool) SetMinConn ¶ added in v2.0.2
set new min conn
type PoolNetconn ¶
type PoolNetconn struct {
// contains filtered or unexported fields
}
THIS IS NOT THREAD-SAFE How to use? this is for one goroutine to wrapper the pool but which only requires one connection.
func (*PoolNetconn) Close ¶
func (p *PoolNetconn) Close() error
func (*PoolNetconn) LocalAddr ¶
func (p *PoolNetconn) LocalAddr() net.Addr
func (*PoolNetconn) ReadFrom ¶ added in v2.0.5
func (p *PoolNetconn) ReadFrom(r io.Reader) (n int64, err error)
func (*PoolNetconn) RemoteAddr ¶
func (p *PoolNetconn) RemoteAddr() net.Addr
func (*PoolNetconn) SetDeadline ¶
func (p *PoolNetconn) SetDeadline(t time.Time) error
func (*PoolNetconn) SetReadDeadline ¶
func (p *PoolNetconn) SetReadDeadline(t time.Time) error
func (*PoolNetconn) SetWriteDeadline ¶
func (p *PoolNetconn) SetWriteDeadline(t time.Time) error
type PoolWrapper ¶
type PoolWrapper struct {
// contains filtered or unexported fields
}
func (*PoolWrapper) Close ¶
func (p *PoolWrapper) Close() error
Click to show internal directories.
Click to hide internal directories.