redis: github.com/go-redis/redis/internal/pool Index | Files

package pool

import "github.com/go-redis/redis/internal/pool"

Index

Package Files

conn.go pool.go pool_single.go pool_sticky.go

Variables

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

type BadConnError Uses

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

func (BadConnError) Error Uses

func (e BadConnError) Error() string

func (BadConnError) Unwrap Uses

func (e BadConnError) Unwrap() error

type Conn Uses

type Conn struct {
    Inited bool
    // contains filtered or unexported fields
}

func NewConn Uses

func NewConn(netConn net.Conn) *Conn

func (*Conn) Close Uses

func (cn *Conn) Close() error

func (*Conn) RemoteAddr Uses

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

func (*Conn) SetNetConn Uses

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

func (*Conn) SetUsedAt Uses

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

func (*Conn) UsedAt Uses

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

func (*Conn) WithReader Uses

func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error

func (*Conn) WithWriter Uses

func (cn *Conn) WithWriter(
    ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error,
) error

func (*Conn) Write Uses

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

type ConnPool Uses

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

func NewConnPool Uses

func NewConnPool(opt *Options) *ConnPool

func (*ConnPool) Close Uses

func (p *ConnPool) Close() error

func (*ConnPool) CloseConn Uses

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

func (*ConnPool) Filter Uses

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

func (*ConnPool) Get Uses

func (p *ConnPool) Get(ctx context.Context) (*Conn, error)

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

func (*ConnPool) IdleLen Uses

func (p *ConnPool) IdleLen() int

IdleLen returns number of idle connections.

func (*ConnPool) Len Uses

func (p *ConnPool) Len() int

Len returns total number of connections.

func (*ConnPool) NewConn Uses

func (p *ConnPool) NewConn(ctx context.Context) (*Conn, error)

func (*ConnPool) Put Uses

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

func (*ConnPool) ReapStaleConns Uses

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

func (*ConnPool) Remove Uses

func (p *ConnPool) Remove(cn *Conn, reason error)

func (*ConnPool) Stats Uses

func (p *ConnPool) Stats() *Stats

type Options Uses

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

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

type Pooler Uses

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

    Get(context.Context) (*Conn, error)
    Put(*Conn)
    Remove(*Conn, error)

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

    Close() error
}

type SingleConnPool Uses

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

func NewSingleConnPool Uses

func NewSingleConnPool(pool Pooler) *SingleConnPool

func (*SingleConnPool) Close Uses

func (p *SingleConnPool) Close() error

func (*SingleConnPool) CloseConn Uses

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

func (*SingleConnPool) Get Uses

func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error)

func (*SingleConnPool) IdleLen Uses

func (p *SingleConnPool) IdleLen() int

func (*SingleConnPool) Len Uses

func (p *SingleConnPool) Len() int

func (*SingleConnPool) NewConn Uses

func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error)

func (*SingleConnPool) Put Uses

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

func (*SingleConnPool) Remove Uses

func (p *SingleConnPool) Remove(cn *Conn, reason error)

func (*SingleConnPool) Reset Uses

func (p *SingleConnPool) Reset() error

func (*SingleConnPool) SetConn Uses

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

func (*SingleConnPool) Stats Uses

func (p *SingleConnPool) Stats() *Stats

type Stats Uses

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
    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 Uses

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

func NewStickyConnPool Uses

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

func (*StickyConnPool) Close Uses

func (p *StickyConnPool) Close() error

func (*StickyConnPool) CloseConn Uses

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

func (*StickyConnPool) Get Uses

func (p *StickyConnPool) Get(ctx context.Context) (*Conn, error)

func (*StickyConnPool) IdleLen Uses

func (p *StickyConnPool) IdleLen() int

func (*StickyConnPool) Len Uses

func (p *StickyConnPool) Len() int

func (*StickyConnPool) NewConn Uses

func (p *StickyConnPool) NewConn(context.Context) (*Conn, error)

func (*StickyConnPool) Put Uses

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

func (*StickyConnPool) Remove Uses

func (p *StickyConnPool) Remove(cn *Conn, reason error)

func (*StickyConnPool) Stats Uses

func (p *StickyConnPool) Stats() *Stats

Package pool imports 9 packages (graph) and is imported by 11 packages. Updated 2019-08-19. Refresh now. Tools for package owners.