pool

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Conn

type Conn struct {
	ldap.Client
	// contains filtered or unexported fields
}

func NewConn

func NewConn(client ldap.Client) *Conn

func (*Conn) SetUsedAt

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

func (*Conn) UsedAt

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

type ConnPool

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

func NewPool

func NewPool(opt *Options) *ConnPool

func (*ConnPool) Close

func (p *ConnPool) Close() error

func (*ConnPool) CloseConn

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

func (*ConnPool) Filter

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

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

IdleLen returns number of idle connections.

func (*ConnPool) Len

func (p *ConnPool) Len() int

Len returns total number of connections.

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 {
	Factory func() (ldap.Client, error)
	OnClose func(*Conn) error

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

type Pooler

type Pooler interface {
	Get() (*Conn, error)
	Put(c *Conn)

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

	Close() error
}

type Stats

type Stats struct {
	Hits     uint32 `json:"hits"`     // number of times free connection was found in the pool
	Misses   uint32 `json:"misses"`   // number of times free connection was NOT found in the pool
	Timeouts uint32 `json:"timeouts"` // number of times a wait timeout occurred

	TotalConns uint32 `json:"totalConns"` // number of total connections in the pool
	IdleConns  uint32 `json:"idelConns"`  // number of idle connections in the pool
	StaleConns uint32 `json:"staleConns"` // number of stale connections removed from the pool
}

Stats contains pool state information and accumulated stats.

Jump to

Keyboard shortcuts

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