Skip to content

Provide ReadPreferenceResolver similar to WriteConcernResolver [DATAMONGO-947] #1856

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

Closed
spring-projects-issues opened this issue Jun 5, 2014 · 2 comments
Assignees
Labels
in: repository Repositories abstraction type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Alexej Kubarev opened DATAMONGO-947 and commented

In some applications it's required to change the readPreference for one or more repository (and keep it distinct from a default ReadPreference set on MongoTemplate).

A mechanism similar to WriteConcernResolver would make this very flexible and achieve this functionality.

Currently there are two workarounds which are not very clean:

  1. Creating repository in question with a different MongoTemplate (does not allow per-action preferences changes)
  2. Subclassing MongoTemplate and hooking in desired functionality there

Affects: 1.5 GA (Dijkstra)

@spring-projects-issues
Copy link
Author

Alexej Kubarev commented

After doing a quick subclassing (workaround #2) myself I realised that it would be great if it's possible to do resolution based on the action performed, not only per collection (as currently allowed by prepareCollection method.

Reason for this addition would be that some operations may need to be done with a different ReadPreference. It's very simple with Mongo Java Driver but MongoTemplate hides this functionality and thus enforces you to either go directly to driver or always use one ReadPreference for all operations (even if it's resolved by Collection, as long as we are not taking Query/Method into consideration).

Unfortunately as pointed out by Oliver, MongoAction is not applicable to find queries and therefore this would be harder to provide such flexibility.

Maybe Repository methods could be annotated with ReadPreference or a class similar to MongoAction (e.g MongoFind) could be added, at least in future iterations of this feature?

@christophstrobl
Copy link
Member

Resolved via: #4288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository Repositories abstraction type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants