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

Add annotation ReadPreference #4503

Conversation

jorgerod
Copy link
Contributor

@jorgerod jorgerod commented Sep 13, 2023

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Closes: #2971

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 13, 2023
@christophstrobl christophstrobl self-assigned this Sep 14, 2023
@christophstrobl
Copy link
Member

Thank you @jorgerod for the PR we'll have a closer look asap.

@jorgerod jorgerod marked this pull request as ready for review September 14, 2023 09:15
@christophstrobl
Copy link
Member

Thank you again @jorgerod for investing time into this feature and creating the PR, which looks very decent 👍

Things we'd need to consider as well are methods inherited from other repository interfaces like findAll if the actual repository interface holds a ReadPreference annotation, so that users are not forced to redeclare those in order to get the desired result.

We do feel that fine grained control, like tags, are better suited for usage with the template API/custom repositories, where one has more control over the actual query and its dynamics. Therefore we think they should not surface on the repository level.
However, having support for SpEL expressions, as we have in other places already, might be beneficial as this would allow us to register beans that can serve as ReadPreference suppliers.

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2023
@jorgerod
Copy link
Contributor Author

Hi @christophstrobl

Sorry for the waiting time but I've been quite busy lately.

The changes you propose seem to me to be correct.
I see that you are making progress in this area.

I will follow your progress.

Thank you

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 10, 2023
christophstrobl pushed a commit that referenced this pull request Oct 12, 2023
The annotation enables a declarative style of defining the ReadPreference to use for individual or all repository queries.

Closes: #2971
Original Pull Request: #4503
christophstrobl added a commit that referenced this pull request Oct 12, 2023
…ethods.

This commit reduces the API surface of the ReadPreference annotation leaving fine grained control such as Tags to the Template API.
Next to supporting read preference for annotated queries we now also make sure to apply read preferences for annotated aggregation methods as well as predefined finder methods running queries.

See: #2971
Original Pull Request: #4503
christophstrobl pushed a commit that referenced this pull request Oct 12, 2023
Tweak documentation wording. Refine constructor nullability rules. Fix javadoc references.

Original Pull Request: #4503
christophstrobl pushed a commit that referenced this pull request Oct 12, 2023
…idden base repository methods.

See: #2971
Original Pull Request: #4503
@christophstrobl
Copy link
Member

Thank you again @jorgerod for your contribution! The changes have been merged to the main development line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting ReadPreference at a Repository and Query level [DATAMONGO-2103]
3 participants