Folks, I am trying to specify an array of MongoDB cluster hosts via my config.
config:
"mongo" : {
"auth":{
"hosts" : [
"ip1","ip2","ip3"
],
"port" : 27017,
"database" : "auth",
code works:
this.server = new mongodb.Server(
host[0],
port,
{auto_reconnect: true});
this.db_connector = new mongodb.Db(this.dbname, this.server);
However, as you see im connecting to only ip1. If I have ec2 instances in separate regions, id like to connect to correct mongo replicas. From what I've read, mongo will figure out which node to write to, and read from based upon replica settings.
What is the proper way of specifying a mongo cluster which is multi-region. I would like to keep all the reads bound to a single region. Assume mongo driver connects to the 'closest' db host.
Thanks!