Skip to content

Add factory method to LettuceConnectionFactory to create RedisConfiguration from RedisURI #2117

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
wants to merge 4 commits into from

Conversation

onobc
Copy link
Contributor

@onobc onobc commented Jul 12, 2021

Fixes gh-2116

@markpollack I know this still needs formatting and tests written but I wanted to push the proposal that I have so far to make sure this is what you had in mind. I will follow on w/ the formatting and tests once you confirm (or not).

Thanks

  • 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).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 12, 2021
Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your pull request. I left a few comments. You can find the formatter settings at https://github.com/spring-projects/spring-data-build/tree/main/etc/ide

@mp911de mp911de self-assigned this Jul 12, 2021
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 12, 2021
@mp911de mp911de added this to the 2.5.3 (2021.0.3) milestone Jul 12, 2021
@onobc
Copy link
Contributor Author

onobc commented Jul 12, 2021

Adding tests now.

 - fix formatting
 - package protect new methods
 - rename factory method
@onobc onobc force-pushed the gh-2116-redisuri branch from bc4d28c to 59eeb78 Compare July 12, 2021 13:26
@onobc
Copy link
Contributor Author

onobc commented Jul 13, 2021

@mp911de well I just realized that "Mark Pollack" whom I mentioned in original description != "Mark Paluch" 🤦.

I am leaving WIP as I want to consume these changes locally to verify it is what we want for spring-projects/spring-boot#21920 so as to avoid any churn in case this proposal needs to be tweaked slightly. I should be able to do that sometime w/in next 24 hrs.

Of course, if you would rather merge it before I do that - that is fine too.

@onobc onobc requested a review from mp911de July 13, 2021 04:07
*
* @author Chris Bono
*/
class LettuceConnectionFactoryCreateRedisConfigurationUnitTests {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things to note about this test:

  1. I opted to test the functionality at LettuceConnectionFactory.createRedisConfiguration rather than directly on the LettuceConverters.redisUriTo<T>Configuration as the tests would have been almost identical. The coverage is the same doing it this way. The assumption is that the LC methods are an internal impl of this API. Also, because the LC methods are static, just unit testing the routing in LCF to LC (that is all that the LCF really is doing) would have been problematic to mock.

  2. I broke it out into its own specific LCF unit test as the other one is getting pretty big.

  3. I leveraged @Nested to group the "flavor" of RedisConfiguration under test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest introducing proper equals/hashCode methods, that's something we can do during the merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh good call. I was wrapped up in Lettuce specific-land that I did not realize the config objects were not lettuce constructs - they are clearly spring data redis and I could have added EHC rather than the AssertJ field by field config approach.

Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty decent. Let me polish up the last bits here and take care of the merge.

@mp911de mp911de changed the title WIP: Add convenience factory method to convert RedisURI to RedisConfiguration Add convenience factory method to create RedisConfiguration from RedisURI Jul 13, 2021
@mp911de mp911de changed the title Add convenience factory method to create RedisConfiguration from RedisURI Add factory method to LettuceConnectionFactory to create RedisConfiguration from RedisURI Jul 13, 2021
mp911de pushed a commit that referenced this pull request Jul 13, 2021
…ration from RedisURI.

Closes #2116.
Original pull request: #2117.
mp911de added a commit that referenced this pull request Jul 13, 2021
Reorder methods. Remove unnecessary null guards. Introduce hashCode/equals methods to RedisConfiguration implementations. Refactor tests. Let LettuceClientConfiguration.builder apply settings from RedisURI. Introduce SentinelMasterId to implement equals method.

See #2116.
Original pull request: #2117.
@mp911de
Copy link
Member

mp911de commented Jul 13, 2021

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this Jul 13, 2021
mp911de pushed a commit that referenced this pull request Jul 13, 2021
…ration from RedisURI.

Closes #2116.
Original pull request: #2117.
mp911de added a commit that referenced this pull request Jul 13, 2021
Reorder methods. Remove unnecessary null guards. Introduce hashCode/equals methods to RedisConfiguration implementations. Refactor tests. Let LettuceClientConfiguration.builder apply settings from RedisURI. Introduce SentinelMasterId to implement equals method.

See #2116.
Original pull request: #2117.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce factory methods to configure LettuceConnectionFactory from RedisURI
3 participants