-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java
Show resolved
Hide resolved
There was a problem hiding this 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
src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java
Outdated
Show resolved
Hide resolved
Adding tests now. |
- fix formatting - package protect new methods - rename factory method
@mp911de well I just realized that "Mark Pollack" whom I mentioned in original description 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. |
src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java
Show resolved
Hide resolved
* | ||
* @author Chris Bono | ||
*/ | ||
class LettuceConnectionFactoryCreateRedisConfigurationUnitTests { |
There was a problem hiding this comment.
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:
-
I opted to test the functionality at
LettuceConnectionFactory.createRedisConfiguration
rather than directly on theLettuceConverters.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. -
I broke it out into its own specific LCF unit test as the other one is getting pretty big.
-
I leveraged
@Nested
to group the "flavor" of RedisConfiguration under test.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
RedisConfiguration
from RedisURI
RedisConfiguration
from RedisURI
LettuceConnectionFactory
to create RedisConfiguration
from RedisURI
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.
Thank you for your contribution. That's merged, polished, and backported now. |
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.
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