MongoDB  2.7.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
mongo::ConnectionString Class Reference

ConnectionString handles parsing different ways to connect to mongo and determining method samples: server server:port foo/server:port,server:port SET server,server,server SYNC Warning - you usually don't want "SYNC", it's used for some special things such as sharding config servers. More...

#include <dbclientinterface.h>

Classes

class  ConnectionHook
 

Public Types

enum  ConnectionType {
  INVALID, MASTER, PAIR, SET,
  SYNC, CUSTOM
}
 

Public Member Functions

 ConnectionString (const HostAndPort &server)
 
 ConnectionString (ConnectionType type, const string &s, const string &setName="")
 
 ConnectionString (const string &s, ConnectionType favoredMultipleType)
 
bool isValid () const
 
string toString () const
 
DBClientBaseconnect (string &errmsg, double socketTimeout=0) const
 
string getSetName () const
 
vector< HostAndPortgetServers () const
 
ConnectionType type () const
 
bool sameLogicalEndpoint (const ConnectionString &other) const
 This returns true if this and other point to the same logical entity. More...
 
bool operator< (const ConnectionString &other) const
 

Static Public Member Functions

static ConnectionString parse (const string &url, string &errmsg)
 
static string typeToString (ConnectionType type)
 
static void setConnectionHook (ConnectionHook *hook)
 
static ConnectionHookgetConnectionHook ()
 
static ConnectionString mock (const HostAndPort &server)
 

Detailed Description

ConnectionString handles parsing different ways to connect to mongo and determining method samples: server server:port foo/server:port,server:port SET server,server,server SYNC Warning - you usually don't want "SYNC", it's used for some special things such as sharding config servers.

See syncclusterconnection.h for more info.

tyipcal use string errmsg, ConnectionString cs = ConnectionString::parse( url , errmsg ); if ( ! cs.isValid() ) throw "bad: " + errmsg; DBClientBase * conn = cs.connect( errmsg );

Member Function Documentation

bool mongo::ConnectionString::sameLogicalEndpoint ( const ConnectionString other) const

This returns true if this and other point to the same logical entity.

For single nodes, thats the same address. For replica sets, thats just the same replica set name. For pair (deprecated) or sync cluster connections, that's the same hosts in any ordering.


The documentation for this class was generated from the following files: