pg.v5: Index | Files

package pool

import ""


Package Files

conn.go pool.go write_buffer.go


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

func SetIdleCheckFrequency Uses

func SetIdleCheckFrequency(d time.Duration)

type Conn Uses

type Conn struct {
    Rd      *bufio.Reader
    Columns [][]byte

    Wr  *WriteBuffer

    InitedAt time.Time
    UsedAt   time.Time

    ProcessId int32
    SecretKey int32
    // contains filtered or unexported fields

func NewConn Uses

func NewConn(netConn net.Conn) *Conn

func (*Conn) CheckHealth Uses

func (cn *Conn) CheckHealth() error

func (*Conn) Close Uses

func (cn *Conn) Close() error

func (*Conn) FlushWriter Uses

func (cn *Conn) FlushWriter() error

func (*Conn) NetConn Uses

func (cn *Conn) NetConn() net.Conn

func (*Conn) NextId Uses

func (cn *Conn) NextId() string

func (*Conn) ReadN Uses

func (cn *Conn) ReadN(n int) ([]byte, error)

func (*Conn) RemoteAddr Uses

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

func (*Conn) SetNetConn Uses

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

func (*Conn) SetReadWriteTimeout Uses

func (cn *Conn) SetReadWriteTimeout(rt, wt time.Duration)

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() (retErr error)

func (*ConnPool) Closed Uses

func (p *ConnPool) Closed() bool

func (*ConnPool) FreeLen Uses

func (p *ConnPool) FreeLen() int

FreeLen returns number of free connections.

func (*ConnPool) Get Uses

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

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

func (*ConnPool) Len Uses

func (p *ConnPool) Len() int

Len returns total number of connections.

func (*ConnPool) NewConn Uses

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

func (*ConnPool) PopFree Uses

func (p *ConnPool) PopFree() *Conn

func (*ConnPool) Put Uses

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

func (*ConnPool) ReapStaleConns Uses

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

func (*ConnPool) Remove Uses

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

func (*ConnPool) Stats Uses

func (p *ConnPool) Stats() *Stats

type Options Uses

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

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

type Pooler Uses

type Pooler interface {
    Get() (*Conn, bool, error)
    Put(*Conn) error
    Remove(*Conn, error) error
    Len() int
    FreeLen() int
    Stats() *Stats
    Close() error
    Closed() bool

type Stats Uses

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

    TotalConns uint32 // the number of total connections in the pool
    FreeConns  uint32 // the number of free connections in the pool

Stats contains pool state information and accumulated stats.

type WriteBuffer Uses

type WriteBuffer struct {
    Bytes []byte
    // contains filtered or unexported fields

func NewWriteBuffer Uses

func NewWriteBuffer() *WriteBuffer

func (*WriteBuffer) FinishMessage Uses

func (buf *WriteBuffer) FinishMessage()

func (*WriteBuffer) FinishNullParam Uses

func (buf *WriteBuffer) FinishNullParam()

func (*WriteBuffer) FinishParam Uses

func (buf *WriteBuffer) FinishParam()

func (*WriteBuffer) ReadFrom Uses

func (buf *WriteBuffer) ReadFrom(r io.Reader) (int64, error)

func (*WriteBuffer) Reset Uses

func (buf *WriteBuffer) Reset()

func (*WriteBuffer) StartMessage Uses

func (buf *WriteBuffer) StartMessage(c byte)

func (*WriteBuffer) StartParam Uses

func (buf *WriteBuffer) StartParam()

func (*WriteBuffer) Write Uses

func (buf *WriteBuffer) Write(b []byte) (int, error)

func (*WriteBuffer) WriteByte Uses

func (buf *WriteBuffer) WriteByte(c byte)

func (*WriteBuffer) WriteBytes Uses

func (buf *WriteBuffer) WriteBytes(b []byte)

func (*WriteBuffer) WriteInt16 Uses

func (buf *WriteBuffer) WriteInt16(num int16)

func (*WriteBuffer) WriteInt32 Uses

func (buf *WriteBuffer) WriteInt32(num int32)

func (*WriteBuffer) WriteString Uses

func (buf *WriteBuffer) WriteString(s string)

Package pool imports 12 packages (graph) and is imported by 1 packages. Updated 2017-03-06. Refresh now. Tools for package owners.