Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MongoDB ReadPreference configuration #156

Closed
jimlambie opened this issue Dec 6, 2016 · 7 comments
Closed

Allow MongoDB ReadPreference configuration #156

jimlambie opened this issue Dec 6, 2016 · 7 comments
Assignees

Comments

@jimlambie
Copy link
Contributor

API needs a way to configure the ReadPreference when connecting to a replica set, as per this page in the docs: https://docs.mongodb.com/v3.0/core/read-preference/

@jimlambie jimlambie added this to the 1.15.0 milestone Dec 21, 2016
@jimlambie
Copy link
Contributor Author

@fra967 can you please confirm this covers what you require for readPreference?

https://docs.mongodb.com/manual/reference/read-preference/

@fra967
Copy link

fra967 commented Jan 12, 2017

We will probably want to set it to secondaryPreferred in order to fall back to the primary.
I believe we also need to issue a rs.slaveOk() before sending the query (at least, that's what needs to be done from the shell, not sure if the drive would do that automatically)

@jimlambie
Copy link
Contributor Author

@fra967 I believe that happens internally, as seen by this getter on the Db class:

// slaveOk specified
Object.defineProperty(Db.prototype, 'slaveOk', {
  enumerable:true,
  get: function() {
    if(this.s.options.readPreference != null
      && (this.s.options.readPreference != 'primary' || this.s.options.readPreference.mode != 'primary')) {
      return true;
    }
    return false;
  }
});

@fra967
Copy link

fra967 commented Jan 20, 2017

cool, so I guess we just need to test it :)

@jimlambie
Copy link
Contributor Author

@fra967 do you have a preference for the default setting? or should secondaryPreferred be default?

@fra967
Copy link

fra967 commented Jan 26, 2017

yes @jimlambie please let's use secondaryPreferred as default value

@jimlambie jimlambie removed this from the 1.15.0 milestone Jan 30, 2017
@jimlambie
Copy link
Contributor Author

Rolled into #171

jimlambie added a commit that referenced this issue Feb 3, 2017
Default to “secondaryPreferred”

Close #156
@jimlambie jimlambie self-assigned this Feb 3, 2017
@jimlambie jimlambie added this to In Progress in API Version 2 Feb 14, 2017
jimlambie added a commit that referenced this issue Apr 27, 2017
Default to “secondaryPreferred”

Close #156
@jimlambie jimlambie moved this from In Progress to Review in API Version 2 May 29, 2017
@jimlambie jimlambie removed this from In progress in API Roadmap May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants