Skip to content

Commit

Permalink
Merge pull request #2145 from denizzzka/mongo_pool_size
Browse files Browse the repository at this point in the history
MongoDB: adds max pool size setting
  • Loading branch information
s-ludwig committed Apr 26, 2018
2 parents 94dbfb3 + fb098d5 commit b06f50e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions mongodb/vibe/db/mongo/client.d
Expand Up @@ -60,10 +60,12 @@ final class MongoClient {
if(!goodUrl) throw new Exception("Unable to parse mongodb URL: " ~ url);

m_connections = new ConnectionPool!MongoConnection(() @safe {
auto ret = new MongoConnection(settings);
ret.connect();
return ret;
});
auto ret = new MongoConnection(settings);
ret.connect();
return ret;
},
settings.maxConnections
);

// force a connection to cause an exception for wrong URLs
lockConnection();
Expand All @@ -72,10 +74,12 @@ final class MongoClient {
package this(MongoClientSettings settings)
{
m_connections = new ConnectionPool!MongoConnection({
auto ret = new MongoConnection(settings);
ret.connect();
return ret;
});
auto ret = new MongoConnection(settings);
ret.connect();
return ret;
},
settings.maxConnections
);

// force a connection to cause an exception for wrong URLs
lockConnection();
Expand Down
1 change: 1 addition & 0 deletions mongodb/vibe/db/mongo/settings.d
Expand Up @@ -321,6 +321,7 @@ class MongoClientSettings

string username;
string digest;
uint maxConnections = uint.max;
MongoHost[] hosts;
string database;
QueryFlags defQueryFlags = QueryFlags.None;
Expand Down

0 comments on commit b06f50e

Please sign in to comment.