Documentation ¶
Index ¶
- Variables
- func PutReaderContext(rd *ReaderContext)
- func PutWriteBuffer(wb *WriteBuffer)
- type BadConnError
- type BufReader
- func (b *BufReader) Available() int
- func (b *BufReader) Buffered() int
- func (b *BufReader) Bytes() []byte
- func (b *BufReader) BytesReader(n int) *BytesReader
- func (b *BufReader) Discard(n int) (discarded int, err error)
- func (b *BufReader) Read(p []byte) (n int, err error)
- func (b *BufReader) ReadByte() (byte, error)
- func (b *BufReader) ReadBytes(fn func(byte) bool) (line []byte, err error)
- func (b *BufReader) ReadFull() ([]byte, error)
- func (b *BufReader) ReadFullTemp() ([]byte, error)
- func (b *BufReader) ReadN(n int) (line []byte, err error)
- func (b *BufReader) ReadSlice(delim byte) (line []byte, err error)
- func (b *BufReader) Reset(rd io.Reader)
- func (b *BufReader) SetAvailable(n int)
- func (b *BufReader) UnreadByte() error
- type 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) ReadBytes(fn func(byte) bool) ([]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
- type ColumnInfo
- type Conn
- func (cn *Conn) Close() error
- func (cn *Conn) LockReader()
- func (cn *Conn) NetConn() net.Conn
- func (cn *Conn) NextID() string
- func (cn *Conn) RemoteAddr() net.Addr
- func (cn *Conn) SetNetConn(netConn net.Conn)
- func (cn *Conn) SetUsedAt(tm time.Time)
- func (cn *Conn) UsedAt() time.Time
- 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
- func (cn *Conn) WriteBuffer(ctx context.Context, timeout time.Duration, wb *WriteBuffer) error
- type ConnPool
- func (p *ConnPool) Close() error
- func (p *ConnPool) CloseConn(cn *Conn) error
- func (p *ConnPool) Filter(fn func(*Conn) bool) error
- func (p *ConnPool) Get(ctx context.Context) (*Conn, error)
- func (p *ConnPool) IdleLen() int
- func (p *ConnPool) Len() int
- func (p *ConnPool) NewConn(c context.Context) (*Conn, error)
- func (p *ConnPool) Put(ctx context.Context, cn *Conn)
- func (p *ConnPool) ReapStaleConns() (int, error)
- func (p *ConnPool) Remove(ctx context.Context, cn *Conn, reason error)
- func (p *ConnPool) Stats() Stats
- type Options
- type Pooler
- type Reader
- type ReaderContext
- type SingleConnPool
- func (p *SingleConnPool) Close() error
- func (p *SingleConnPool) CloseConn(cn *Conn) error
- func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error)
- func (p *SingleConnPool) IdleLen() int
- func (p *SingleConnPool) Len() int
- func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error)
- func (p *SingleConnPool) Put(ctx context.Context, cn *Conn)
- func (p *SingleConnPool) Remove(ctx context.Context, cn *Conn, reason error)
- func (p *SingleConnPool) Stats() Stats
- type Stats
- type StickyConnPool
- func (p *StickyConnPool) Close() error
- func (p *StickyConnPool) CloseConn(cn *Conn) error
- func (p *StickyConnPool) Get(ctx context.Context) (*Conn, error)
- func (p *StickyConnPool) IdleLen() int
- func (p *StickyConnPool) Len() int
- func (p *StickyConnPool) NewConn(ctx context.Context) (*Conn, error)
- func (p *StickyConnPool) Put(ctx context.Context, cn *Conn)
- func (p *StickyConnPool) Remove(ctx context.Context, cn *Conn, reason error)
- func (p *StickyConnPool) Reset(ctx context.Context) error
- func (p *StickyConnPool) Stats() Stats
- type WriteBuffer
- func (buf *WriteBuffer) FinishMessage()
- func (buf *WriteBuffer) FinishNullParam()
- func (buf *WriteBuffer) FinishParam()
- func (buf *WriteBuffer) Query() []byte
- func (buf *WriteBuffer) ReadFrom(r io.Reader) (int64, error)
- 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)
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("pg: database is closed") ErrPoolTimeout = errors.New("pg: connection pool timeout") )
Functions ¶
func PutReaderContext ¶
func PutReaderContext(rd *ReaderContext)
func PutWriteBuffer ¶
func PutWriteBuffer(wb *WriteBuffer)
Types ¶
type BadConnError ¶
type BadConnError struct {
// contains filtered or unexported fields
}
func (BadConnError) Error ¶
func (e BadConnError) Error() string
func (BadConnError) Unwrap ¶
func (e BadConnError) Unwrap() error
type BufReader ¶
type BufReader struct {
// contains filtered or unexported fields
}
func NewBufReader ¶
func (*BufReader) Buffered ¶
Buffered returns the number of bytes that can be read from the current buffer.
func (*BufReader) BytesReader ¶
func (b *BufReader) BytesReader(n int) *BytesReader
func (*BufReader) Discard ¶
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.
func (*BufReader) ReadFullTemp ¶
func (*BufReader) ReadSlice ¶
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.
func (*BufReader) SetAvailable ¶
func (*BufReader) UnreadByte ¶
type BytesReader ¶
type BytesReader struct {
// contains filtered or unexported fields
}
func NewBytesReader ¶
func NewBytesReader(b []byte) *BytesReader
func (*BytesReader) Buffered ¶
func (r *BytesReader) Buffered() int
func (*BytesReader) Bytes ¶
func (r *BytesReader) Bytes() []byte
func (*BytesReader) ReadByte ¶
func (r *BytesReader) ReadByte() (byte, error)
func (*BytesReader) ReadFull ¶
func (r *BytesReader) ReadFull() ([]byte, error)
func (*BytesReader) ReadFullTemp ¶
func (r *BytesReader) ReadFullTemp() ([]byte, error)
func (*BytesReader) Reset ¶
func (r *BytesReader) Reset(b []byte)
func (*BytesReader) UnreadByte ¶
func (r *BytesReader) UnreadByte() error
type ColumnAlloc ¶
type ColumnAlloc struct {
// contains filtered or unexported fields
}
func NewColumnAlloc ¶
func NewColumnAlloc() *ColumnAlloc
func (*ColumnAlloc) Columns ¶
func (c *ColumnAlloc) Columns() []ColumnInfo
func (*ColumnAlloc) New ¶
func (c *ColumnAlloc) New(index int16, name []byte) *ColumnInfo
func (*ColumnAlloc) Reset ¶
func (c *ColumnAlloc) Reset()
type ColumnInfo ¶
type Conn ¶
type Conn struct { ProcessID int32 SecretKey int32 Inited bool // contains filtered or unexported fields }
func (*Conn) LockReader ¶
func (cn *Conn) LockReader()
func (*Conn) RemoteAddr ¶
func (*Conn) SetNetConn ¶
func (*Conn) WithReader ¶
func (*Conn) WithWriter ¶
func (*Conn) WriteBuffer ¶
type ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
func NewConnPool ¶
func (*ConnPool) ReapStaleConns ¶
type Reader ¶
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 ¶
type ReaderContext struct { *BufReader ColumnAlloc *ColumnAlloc }
func GetReaderContext ¶
func GetReaderContext() *ReaderContext
func NewReaderContext ¶
func NewReaderContext() *ReaderContext
type SingleConnPool ¶
type SingleConnPool struct {
// contains filtered or unexported fields
}
func NewSingleConnPool ¶
func NewSingleConnPool(pool Pooler, cn *Conn) *SingleConnPool
func (*SingleConnPool) Close ¶
func (p *SingleConnPool) Close() error
func (*SingleConnPool) CloseConn ¶
func (p *SingleConnPool) CloseConn(cn *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(ctx context.Context) (*Conn, error)
func (*SingleConnPool) Remove ¶
func (p *SingleConnPool) Remove(ctx context.Context, cn *Conn, reason error)
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 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 Pooler) *StickyConnPool
func (*StickyConnPool) Close ¶
func (p *StickyConnPool) Close() error
func (*StickyConnPool) CloseConn ¶
func (p *StickyConnPool) CloseConn(cn *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(ctx context.Context) (*Conn, error)
func (*StickyConnPool) Remove ¶
func (p *StickyConnPool) Remove(ctx context.Context, cn *Conn, reason error)
func (*StickyConnPool) Stats ¶
func (p *StickyConnPool) Stats() Stats
type WriteBuffer ¶
type WriteBuffer struct { Bytes []byte // contains filtered or unexported fields }
func GetWriteBuffer ¶
func GetWriteBuffer() *WriteBuffer
func NewWriteBuffer ¶
func NewWriteBuffer() *WriteBuffer
func (*WriteBuffer) FinishMessage ¶
func (buf *WriteBuffer) FinishMessage()
func (*WriteBuffer) FinishNullParam ¶
func (buf *WriteBuffer) FinishNullParam()
func (*WriteBuffer) FinishParam ¶
func (buf *WriteBuffer) FinishParam()
func (*WriteBuffer) Query ¶
func (buf *WriteBuffer) Query() []byte
func (*WriteBuffer) Reset ¶
func (buf *WriteBuffer) Reset()
func (*WriteBuffer) StartMessage ¶
func (buf *WriteBuffer) StartMessage(c byte)
func (*WriteBuffer) StartParam ¶
func (buf *WriteBuffer) StartParam()
func (*WriteBuffer) WriteByte ¶
func (buf *WriteBuffer) WriteByte(c byte) error
func (*WriteBuffer) WriteBytes ¶
func (buf *WriteBuffer) WriteBytes(b []byte)
func (*WriteBuffer) WriteInt16 ¶
func (buf *WriteBuffer) WriteInt16(num int16)
func (*WriteBuffer) WriteInt32 ¶
func (buf *WriteBuffer) WriteInt32(num int32)
func (*WriteBuffer) WriteString ¶
func (buf *WriteBuffer) WriteString(s string)