LdapConnectionPool constructor
LdapConnectionPool(
- LdapConnection connection, {
- dynamic poolSize = 5,
- dynamic maxOpenRetries = 10,
- dynamic keepAliveTimerSeconds = 30,
- LdapFunction keepAliveFunction = _defaultKeepAliveFunction,
Create a connection pool based on a prototype LdapConnection. The pool
will be up to poolSize
copies of the connection. An
attempt to open the connection up to maxOpenRetries
will be made
with an interval of 10 seconds between each attempt.
Every keepAliveTimerSeconds
the pool will send a keep alive
request to the server. The default keep alive function
sends an Ldap Abandon request with message id = 0. Most servers
will ignore this request.
Implementation
LdapConnectionPool(
LdapConnection connection, {
poolSize = 5,
maxOpenRetries = 10,
keepAliveTimerSeconds = 30,
LdapFunction keepAliveFunction = _defaultKeepAliveFunction,
}) : _protoConnection = connection,
_poolSize = poolSize,
_maxOpenRetries = maxOpenRetries,
_keepAliveFunction = keepAliveFunction,
_keepAliveTimerSeconds = keepAliveTimerSeconds {
assert(_poolSize >= 1 && _poolSize < 20);
var l = <LdapConnection>[];
for (var i = 0; i < _poolSize; ++i) {
var c = LdapConnection.copy(_protoConnection);
c.connectionInfo.id = c.connectionId;
l.add(c);
}
_connections = List.unmodifiable(l);
// create a keep alive timer
Timer.periodic(Duration(seconds: _keepAliveTimerSeconds), (timer) {
for (var connection in _connections) {
_keepAliveFunction(connection);
}
});
}