This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = MongoClient( | |
‘mongodb://hostA,hostB/?replicaSet=my_rs’) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $client = MongoDB::MongoClient->new({ | |
host => "mongodb://hostA,hostB/?replicaSet=my_rs" | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoc_client_t *client = mongoc_client_new ( | |
"mongodb://hostA,hostB/?replicaSet=my_rs"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoc_client_pool_t *pool = mongoc_client_pool_new ( | |
"mongodb://hostA,hostB/?replicaSet=my_rs"); | |
mongoc_client_t *client = mongoc_client_pool_pop (pool); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ismaster = { | |
"setName": "my_rs", | |
"ismaster": false, | |
"secondary": true, | |
"hosts": [ | |
"hostA:27017", | |
"hostB:27017", | |
"hostC:27017"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db = client.get_database("dbname", read_preference=ReadPreference.SECONDARY) | |
# Unblocks when a secondary is found. | |
db.collection.find_one() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ismaster = { | |
"setName": "my_rs", | |
"ismaster": true, | |
"secondary": false, | |
"hosts": [ | |
"hostA:27017", | |
"hostB:27017", | |
"hostC:27017"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoc_client_t *client = mongoc_client_new ( | |
"mongodb://hostA,hostB/?replicaSet=my_rs"0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoc_client_pool_t *pool = mongoc_client_pool_new ( | |
"mongodb://hostA,hostB/?replicaSet=my_rs"); | |
mongoc_client_t *client = mongoc_client_pool_pop (pool); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ismaster = { | |
"setName": "my_rs", | |
"ismaster": false, | |
"secondary": true, | |
"primary": "hostC:27017", | |
"hosts": [ | |
"hostA:27017", | |
"hostB:27017", | |
"hostC:27017"]} |