diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2015-09-25 16:19:01 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2015-10-13 21:26:12 -0400 |
commit | 53c52c43a99d14a9e6c47bcc1ca1e7a2fa044ef0 (patch) | |
tree | 7fbc2ff93c5ac378c14edaa8e49173c6786af86e /src/mongo/client/connection_string.cpp | |
parent | 90cd064713dfcf5c82be07742f7377c83ea0a4f2 (diff) | |
download | mongo-53c52c43a99d14a9e6c47bcc1ca1e7a2fa044ef0.tar.gz |
SERVER-6233 Add URI parsing to mongo shell
Diffstat (limited to 'src/mongo/client/connection_string.cpp')
-rw-r--r-- | src/mongo/client/connection_string.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/mongo/client/connection_string.cpp b/src/mongo/client/connection_string.cpp index b2802343646..69b3f952039 100644 --- a/src/mongo/client/connection_string.cpp +++ b/src/mongo/client/connection_string.cpp @@ -53,19 +53,13 @@ ConnectionString::ConnectionString(ConnectionType type, _type = type; _setName = setName; _fillServers(s); + _finishInit(); +} - switch (_type) { - case MASTER: - verify(_servers.size() == 1); - break; - case SET: - verify(_setName.size()); - verify(_servers.size() >= 1); // 1 is ok since we can derive - break; - default: - verify(_servers.size() > 0); - } - +ConnectionString::ConnectionString(ConnectionType type, + std::vector<HostAndPort> servers, + const std::string& setName) + : _type(type), _servers(std::move(servers)), _setName(setName) { _finishInit(); } @@ -118,6 +112,18 @@ void ConnectionString::_fillServers(std::string s) { } void ConnectionString::_finishInit() { + switch (_type) { + case MASTER: + verify(_servers.size() == 1); + break; + case SET: + verify(_setName.size()); + verify(_servers.size() >= 1); // 1 is ok since we can derive + break; + default: + verify(_servers.size() > 0); + } + // Needed here as well b/c the parsing logic isn't used in all constructors // TODO: Refactor so that the parsing logic *is* used in all constructors if (_type == MASTER && _servers.size() > 0) { |