Introduction
This module provides a connection pool implementation for LDAP connections, allowing efficient reuse of connections in multi-threaded applications.
Example Usage
%new-style
%require-types
%strict-args
%requires LdapConnectionPool
# Create a connection pool
LdapConnectionPool pool("ldap://localhost:389", {
"binddn": "cn=admin,dc=example,dc=com",
"password": "admin",
"timeout": 30s,
}, {
"min_connections": 2,
"max_connections": 10,
"idle_timeout": 300s,
});
# Get a connection from the pool
LdapClient ldap = pool.get();
# Use the connection
hash<auto> result = ldap.search({"base": "dc=example,dc=com", "filter": "(objectClass=*)"});
# Return the connection to the pool
pool.release(ldap);
# Or use the callback pattern
pool.withConnection(sub(LdapClient ldap) {
hash<auto> result = ldap.search({"base": "dc=example,dc=com", "filter": "(objectClass=*)"});
});