go-mgo/mgo — pull request #51 by deafgoat (2014-11-24 16:01:33+00:00)
Title: Enable replica set name assertion in server discovery

Hi Gustavo,

The changes here are meant to address [issue 45](https://github.com/go-mgo/mgo/issues/45). In summary:

- The "DialInfo" struct now accepts a "ReplicaSetName" field that if non-empty, is used to ensure all nodes found during discovery belong to the provided replica set (this is used for sessions established with the "DialWithInfo" function).
- The "DialWithTimeout" function is also updated to check for the replica set name and set the"ReplicaSetName" field.
- Refactored a bit of the tests to check for "ErrNoReachableServers" instead of a string literal.

Important details
- For session establishment, an error is returned if no seed node is part of the replica set. If at least one node is part of the replica set, other non-member seeds are discarded. The usual mechanisms around discovery work as before.
- If no seed node is part of the replica set, an error is returned on dial.
- If no "ReplicaSetName" is provided, session establishment works as before - with the assumption that the servers supplied are either individual mongod servers or mongos routers.

Please take a look and let me know if anything is amiss.

Thanks,
Wisdom.