pool

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 7 Imported by: 0

README

LDAP connection pooling

This implementation is largely based on a very nice implementation by @vetinari.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed is returned when the pool was closed
	ErrClosed = errors.New("pool closed")
)

Functions

This section is empty.

Types

type Conn

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

Conn implements Client to override the Close() method

func (*Conn) Add

func (c *Conn) Add(addRequest *ldap.AddRequest) error

Add wraps the Add LDAP client method

func (*Conn) Bind

func (c *Conn) Bind(username, password string) error

Bind wraps the Bind LDAP client method

func (*Conn) Close

func (c *Conn) Close()

Close puts the connection back to the pool instead of closing it

func (*Conn) Compare

func (c *Conn) Compare(dn, attribute, value string) (bool, error)

Compare wraps the Compare LDAP client method

func (*Conn) Del

func (c *Conn) Del(delRequest *ldap.DelRequest) error

Del wraps the Del LDAP client method

func (*Conn) Modify

func (c *Conn) Modify(modifyRequest *ldap.ModifyRequest) error

Modify wraps the Modify LDAP client method

func (*Conn) ModifyDN

func (c *Conn) ModifyDN(modifyDnRequest *ldap.ModifyDNRequest) error

ModifyDN wraps the ModifyDN LDAP client method

func (*Conn) PasswordModify

func (c *Conn) PasswordModify(passwordModifyRequest *ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error)

PasswordModify wraps the PasswordModify LDAP client method

func (*Conn) Search

func (c *Conn) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

Search wraps the Search LDAP client method

func (*Conn) SearchWithPaging

func (c *Conn) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

SearchWithPaging wraps the SearchWithPaging LDAP client method

func (*Conn) SimpleBind

func (c *Conn) SimpleBind(simpleBindRequest *ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error)

SimpleBind wraps the SimpleBind LDAP client method

func (*Conn) Start

func (c *Conn) Start()

Start starts connection

func (*Conn) StartTLS

func (c *Conn) StartTLS(config *tls.Config) error

StartTLS starts TLS connection

type ConnectionFactory

type ConnectionFactory func() (ldap.Client, error)

ConnectionFactory is a function to create new connections.

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() (*Conn, error)

	// NewConnection returns a new LDAP connection not managed by the pool.
	NewConnection() (ldap.Client, error)

	// Close closes the pool and all its connections.
	Close()

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

Pool is the connection pool interface

func NewChannelPool

func NewChannelPool(capacity, maxCapacity uint, factory ConnectionFactory, reset ResetFunc) (Pool, error)

NewChannelPool creates a new connection pool using a buffered channel

type ResetFunc

type ResetFunc func(conn ldap.Client) error

ResetFunc is a function to reset connections.

Jump to

Keyboard shortcuts

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