pool

package
v6.13.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("redis: client is closed")
View Source
var ErrPoolTimeout = errors.New("redis: connection pool timeout")

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Rd *proto.Reader
	Wb *proto.WriteBuffer

	Inited bool
	// contains filtered or unexported fields
}

func NewConn

func NewConn(netConn net.Conn) *Conn

func (*Conn) Close

func (cn *Conn) Close() error

func (*Conn) IsStale

func (cn *Conn) IsStale(timeout time.Duration) bool

func (*Conn) RemoteAddr

func (cn *Conn) RemoteAddr() net.Addr

func (*Conn) SetNetConn

func (cn *Conn) SetNetConn(netConn net.Conn)

func (*Conn) SetReadTimeout

func (cn *Conn) SetReadTimeout(timeout time.Duration)

func (*Conn) SetUsedAt

func (cn *Conn) SetUsedAt(tm time.Time)

func (*Conn) SetWriteTimeout

func (cn *Conn) SetWriteTimeout(timeout time.Duration)

func (*Conn) UsedAt

func (cn *Conn) UsedAt() time.Time

func (*Conn) Write

func (cn *Conn) Write(b []byte) (int, error)

type ConnPool

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

func NewConnPool

func NewConnPool(opt *Options) *ConnPool

func (*ConnPool) Close

func (p *ConnPool) Close() error

func (*ConnPool) CloseConn

func (p *ConnPool) CloseConn(cn *Conn) error

func (*ConnPool) Filter

func (p *ConnPool) Filter(fn func(*Conn) bool) error

func (*ConnPool) Get

func (p *ConnPool) Get() (*Conn, error)

Get returns existed connection from the pool or creates a new one.

func (*ConnPool) IdleLen

func (p *ConnPool) IdleLen() int

FreeLen returns number of idle connections.

func (*ConnPool) Len

func (p *ConnPool) Len() int

Len returns total number of connections.

func (*ConnPool) NewConn

func (p *ConnPool) NewConn() (*Conn, error)

func (*ConnPool) Put

func (p *ConnPool) Put(cn *Conn)

func (*ConnPool) ReapStaleConns

func (p *ConnPool) ReapStaleConns() (int, error)

func (*ConnPool) Remove

func (p *ConnPool) Remove(cn *Conn)

func (*ConnPool) Stats

func (p *ConnPool) Stats() *Stats

type Options

type Options struct {
	Dialer  func() (net.Conn, error)
	OnClose func(*Conn) error

	PoolSize           int
	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration
}

type Pooler

type Pooler interface {
	NewConn() (*Conn, error)
	CloseConn(*Conn) error

	Get() (*Conn, error)
	Put(*Conn)
	Remove(*Conn)

	Len() int
	IdleLen() int
	Stats() *Stats

	Close() error
}

type SingleConnPool

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

func NewSingleConnPool

func NewSingleConnPool(cn *Conn) *SingleConnPool

func (*SingleConnPool) Close

func (p *SingleConnPool) Close() error

func (*SingleConnPool) CloseConn

func (p *SingleConnPool) CloseConn(*Conn) error

func (*SingleConnPool) Get

func (p *SingleConnPool) Get() (*Conn, error)

func (*SingleConnPool) IdleLen

func (p *SingleConnPool) IdleLen() int

func (*SingleConnPool) Len

func (p *SingleConnPool) Len() int

func (*SingleConnPool) NewConn

func (p *SingleConnPool) NewConn() (*Conn, error)

func (*SingleConnPool) Put

func (p *SingleConnPool) Put(cn *Conn)

func (*SingleConnPool) Remove

func (p *SingleConnPool) Remove(cn *Conn)

func (*SingleConnPool) Stats

func (p *SingleConnPool) Stats() *Stats

type Stats

type Stats struct {
	Hits     uint32 // number of times free connection was found in the pool
	Misses   uint32 // number of times free connection was NOT found in the pool
	Timeouts uint32 // number of times a wait timeout occurred

	TotalConns uint32 // number of total connections in the pool
	FreeConns  uint32 // deprecated - use IdleConns
	IdleConns  uint32 // number of idle connections in the pool
	StaleConns uint32 // number of stale connections removed from the pool
}

Stats contains pool state information and accumulated stats.

type StickyConnPool

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

func NewStickyConnPool

func NewStickyConnPool(pool *ConnPool, reusable bool) *StickyConnPool

func (*StickyConnPool) Close

func (p *StickyConnPool) Close() error

func (*StickyConnPool) CloseConn

func (p *StickyConnPool) CloseConn(*Conn) error

func (*StickyConnPool) Get

func (p *StickyConnPool) Get() (*Conn, error)

func (*StickyConnPool) IdleLen

func (p *StickyConnPool) IdleLen() int

func (*StickyConnPool) Len

func (p *StickyConnPool) Len() int

func (*StickyConnPool) NewConn

func (p *StickyConnPool) NewConn() (*Conn, error)

func (*StickyConnPool) Put

func (p *StickyConnPool) Put(cn *Conn)

func (*StickyConnPool) Remove

func (p *StickyConnPool) Remove(cn *Conn)

func (*StickyConnPool) Stats

func (p *StickyConnPool) Stats() *Stats

Jump to

Keyboard shortcuts

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