ldappool

package
v0.0.0-...-ded6435 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed is the error resulting if the pool is closed via pool.Close().
	ErrClosed = errors.New("pool is closed")
)

Functions

This section is empty.

Types

type Pool

type Pool interface {
	// Get returns a new connection from the pool. Closing the connections puts
	// it back to the Pool. Closing it when the pool is destroyed or full will
	// be counted as an error.
	Get() (*PoolConn, error)

	// Close closes the pool and all its connections. After Close() the pool is
	// no longer usable.
	Close()

	// Len returns the current number of connections of the pool.
	Len() int
}

Pool interface describes a pool implementation. A pool should have maximum capacity. An ideal pool is threadsafe and easy to use.

func NewChannelPool

func NewChannelPool(initialCap, maxCap int, name string, factory PoolFactory, closeAt []uint8) (Pool, error)

NewChannelPool returns a new pool based on buffered channels with an initial capacity and maximum capacity. Factory is used when initial capacity is greater than zero to fill the pool. A zero initialCap doesn't fill the Pool until a new Get() is called. During a Get(), If there is no new connection available in the pool, a new connection will be created via the Factory() method.

closeAt will automagically mark the connection as unusable if the return code of the call is one of those passed, most likely you want to set this to something like

[]uint8{ldap.LDAPResultTimeLimitExceeded, ldap.ErrorNetwork}

type PoolConn

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

PoolConn implements Client to override the Close() method

func (*PoolConn) Add

func (p *PoolConn) Add(addRequest *ldap.AddRequest) error

func (*PoolConn) Bind

func (p *PoolConn) Bind(username, password string) error

func (*PoolConn) Close

func (p *PoolConn) Close()

Close() puts the given connects back to the pool instead of closing it.

func (*PoolConn) Compare

func (p *PoolConn) Compare(dn, attribute, value string) (bool, error)

func (*PoolConn) Del

func (p *PoolConn) Del(delRequest *ldap.DelRequest) error

func (*PoolConn) MarkUnusable

func (p *PoolConn) MarkUnusable()

MarkUnusable() marks the connection not usable any more, to let the pool close it instead of returning it to pool.

func (*PoolConn) Modify

func (p *PoolConn) Modify(modifyRequest *ldap.ModifyRequest) error

func (*PoolConn) PasswordModify

func (p *PoolConn) PasswordModify(passwordModifyRequest *ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error)

func (*PoolConn) Search

func (p *PoolConn) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

func (*PoolConn) SearchWithPaging

func (p *PoolConn) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

func (*PoolConn) SetTimeout

func (p *PoolConn) SetTimeout(t time.Duration)

func (*PoolConn) SimpleBind

func (p *PoolConn) SimpleBind(simpleBindRequest *ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error)

func (*PoolConn) Start

func (p *PoolConn) Start()

func (*PoolConn) StartTLS

func (p *PoolConn) StartTLS(config *tls.Config) error

type PoolFactory

type PoolFactory func(string) (ldap.Client, error)

PoolFactory is a function to create new connections.

Jump to

Keyboard shortcuts

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