Skip to content

Commit

Permalink
chore: collapse some code
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Aug 8, 2024
1 parent 2bc2126 commit d778b3f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/CommonLib/ConnectionPoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,8 @@ private bool GetPool(string identifier, out LdapConnectionPool pool) {

public async Task<(bool Success, LdapConnectionWrapper ConnectionWrapper, string Message)> GetLdapConnection(
string identifier, bool globalCatalog) {
if (identifier == null) {
return (false, default, "Provided a null identifier for the connection");
}
var resolved = ResolveIdentifier(identifier);

if (!_pools.TryGetValue(resolved, out var pool)) {
pool = new LdapConnectionPool(identifier, resolved, _ldapConfig,scanner: _portScanner);
_pools.TryAdd(resolved, pool);
if (!GetPool(identifier, out var pool)) {
return (false, default, $"Unable to resolve a pool for {identifier}");
}

if (globalCatalog) {
Expand All @@ -107,11 +101,8 @@ private bool GetPool(string identifier, out LdapConnectionPool pool) {

public async Task<(bool Success, LdapConnectionWrapper connectionWrapper, string Message)> GetLdapConnectionForServer(
string identifier, string server, bool globalCatalog) {
var resolved = ResolveIdentifier(identifier);

if (!_pools.TryGetValue(resolved, out var pool)) {
pool = new LdapConnectionPool(resolved, identifier, _ldapConfig,scanner: _portScanner);
_pools.TryAdd(resolved, pool);
if (!GetPool(identifier, out var pool)) {
return (false, default, $"Unable to resolve a pool for {identifier}");
}

return await pool.GetConnectionForSpecificServerAsync(server, globalCatalog);
Expand Down

0 comments on commit d778b3f

Please sign in to comment.