import "github.com/go-pg/pg/internal/pool"
conn.go pool.go pool_single.go pool_sticky.go reader.go reader_buf.go reader_bytes.go write_buffer.go
var ( ErrClosed = errors.New("pg: database is closed") ErrPoolTimeout = errors.New("pg: connection pool timeout") )
func PutReaderContext(rd *ReaderContext)
func PutWriteBuffer(wb *WriteBuffer)
type BadConnError struct {
// contains filtered or unexported fields
}
func (e BadConnError) Error() string
func (e BadConnError) Unwrap() error
type BufReader struct {
// contains filtered or unexported fields
}
Buffered returns the number of bytes that can be read from the current buffer.
func (b *BufReader) BytesReader(n int) *BytesReader
Discard skips the next n bytes, returning the number of bytes discarded.
If Discard skips fewer than n bytes, it also returns an error. If 0 <= n <= b.Buffered(), Discard is guaranteed to succeed without reading from the underlying io.BufReader.
ReadSlice reads until the first occurrence of delim in the input, returning a slice pointing at the bytes in the buffer. The bytes stop being valid at the next read. If ReadSlice encounters an error before finding a delimiter, it returns all the data in the buffer and the error itself (often io.EOF). ReadSlice fails with error ErrBufferFull if the buffer fills without a delim. Because the data returned from ReadSlice will be overwritten by the next I/O operation, most clients should use ReadBytes or ReadString instead. ReadSlice returns err != nil if and only if line does not end in delim.
type BytesReader struct {
// contains filtered or unexported fields
}
func NewBytesReader(b []byte) *BytesReader
func (r *BytesReader) Buffered() int
func (r *BytesReader) Bytes() []byte
func (r *BytesReader) Discard(n int) (int, error)
func (r *BytesReader) Read(b []byte) (n int, err error)
func (r *BytesReader) ReadByte() (byte, error)
func (r *BytesReader) ReadFull() ([]byte, error)
func (r *BytesReader) ReadFullTemp() ([]byte, error)
func (r *BytesReader) ReadN(n int) ([]byte, error)
func (r *BytesReader) ReadSlice(delim byte) ([]byte, error)
func (r *BytesReader) Reset(b []byte)
func (r *BytesReader) UnreadByte() error
type ColumnAlloc struct {
// contains filtered or unexported fields
}
func NewColumnAlloc() *ColumnAlloc
func (c *ColumnAlloc) Columns() []ColumnInfo
func (c *ColumnAlloc) New(index int16, name []byte) *ColumnInfo
func (c *ColumnAlloc) Reset()
type Conn struct { ProcessID int32 SecretKey int32 Inited bool // contains filtered or unexported fields }
func (cn *Conn) WithReader( ctx context.Context, timeout time.Duration, fn func(rd *ReaderContext) error, ) error
func (cn *Conn) WithWriter( ctx context.Context, timeout time.Duration, fn func(wb *WriteBuffer) error, ) error
type ConnPool struct {
// contains filtered or unexported fields
}
Get returns existed connection from the pool or creates a new one.
IdleLen returns number of idle connections.
Len returns total number of connections.
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 interface { NewConn(context.Context) (*Conn, error) CloseConn(*Conn) error Get(context.Context) (*Conn, error) Put(context.Context, *Conn) Remove(context.Context, *Conn, error) Len() int IdleLen() int Stats() *Stats Close() error }
type Reader interface { Buffered() int Bytes() []byte Read([]byte) (int, error) ReadByte() (byte, error) UnreadByte() error ReadSlice(byte) ([]byte, error) Discard(int) (int, error) // ReadBytes(fn func(byte) bool) ([]byte, error) // ReadN(int) ([]byte, error) ReadFull() ([]byte, error) ReadFullTemp() ([]byte, error) }
type ReaderContext struct { *BufReader ColumnAlloc *ColumnAlloc }
func GetReaderContext() *ReaderContext
func NewReaderContext() *ReaderContext
type SingleConnPool struct {
// contains filtered or unexported fields
}
func NewSingleConnPool(pool Pooler, cn *Conn) *SingleConnPool
func (p *SingleConnPool) Close() error
func (p *SingleConnPool) CloseConn(cn *Conn) error
func (p *SingleConnPool) IdleLen() int
func (p *SingleConnPool) Len() int
func (p *SingleConnPool) Put(ctx context.Context, cn *Conn)
func (p *SingleConnPool) Stats() *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 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 struct {
// contains filtered or unexported fields
}
func NewStickyConnPool(pool Pooler) *StickyConnPool
func (p *StickyConnPool) Close() error
func (p *StickyConnPool) CloseConn(cn *Conn) error
func (p *StickyConnPool) IdleLen() int
func (p *StickyConnPool) Len() int
func (p *StickyConnPool) Put(ctx context.Context, cn *Conn)
func (p *StickyConnPool) Reset(ctx context.Context) error
func (p *StickyConnPool) Stats() *Stats
func GetWriteBuffer() *WriteBuffer
func NewWriteBuffer() *WriteBuffer
func (buf *WriteBuffer) FinishMessage()
func (buf *WriteBuffer) FinishNullParam()
func (buf *WriteBuffer) FinishParam()
func (buf *WriteBuffer) Query() []byte
func (buf *WriteBuffer) Reset()
func (buf *WriteBuffer) StartMessage(c byte)
func (buf *WriteBuffer) StartParam()
func (buf *WriteBuffer) Write(b []byte) (int, error)
func (buf *WriteBuffer) WriteByte(c byte) error
func (buf *WriteBuffer) WriteBytes(b []byte)
func (buf *WriteBuffer) WriteInt16(num int16)
func (buf *WriteBuffer) WriteInt32(num int32)
func (buf *WriteBuffer) WriteString(s string)
Package pool imports 15 packages (graph) and is imported by 14 packages. Updated 2020-12-05. Refresh now. Tools for package owners.