mongodb/mongo-c-driver — pull request #41 by ijammy (2012-05-24 09:18:59+00:00)
Title: Feature: slaveOk && DataCenter awareness

How to use?

Before calling mongo_replset_connect,

set conn->flags = MONGO_SLAVE_OK
set conn->preferred_tag = "cloud"
set conn->tag_name = "DC"

then the host "E" will be chosen!

{
_id : "someSet",
members : [
{_id : 0, host : "A", tags : {"DC": "ny"}},
{_id : 1, host : "B", tags : {"DC": "ny"}},
{_id : 2, host : "C", tags : {"DC": "sf"}},
{_id : 3, host : "D", tags : {"DC": "sf"}},
{_id : 4, host : "E", tags : {"DC": "cloud"}}
]