-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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 spring.data.redis.lettuce.read-from property #42588
base: main
Are you sure you want to change the base?
Conversation
Thanks, @nosan. Unfortunately, when I looked at this yesterday, I mistakenly thought that I wonder if we could still use a single property. The values that map directly to a I don't want to waste any more of your time (apologies again for the time possibly already wasted) so please don't do anything about the above until we've had a chance to discuss this as a team. |
Thanks, @wilkinsona. |
@Bean
@ConfigurationPropertiesBinding
StringToReadFromConverter stringToReadFromConverter() {
return new StringToReadFromConverter();
}
static class StringToReadFromConverter implements GenericConverter {
private static final Set<ConvertiblePair> CONVERTIBLE_TYPES;
static {
CONVERTIBLE_TYPES = Set.of(new ConvertiblePair(String.class, ReadFrom.class));
}
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return CONVERTIBLE_TYPES;
}
@Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
if (source == null) {
return null;
}
String value = source.toString();
int index = value.indexOf(':');
if (index != -1) {
String type = value.substring(0, index);
if (type.equalsIgnoreCase("subnet")) {
return ReadFrom.subnet(StringUtils.commaDelimitedListToStringArray(value.substring(index + 1)));
}
if (type.equalsIgnoreCase("regex")) {
return ReadFrom.regex(Pattern.compile(value.substring(index + 1)));
}
}
return ReadFrom.valueOf(value);
}
}
in that case, it will be possible to use the following syntax: spring.data.redis.lettuce.read-from=regex:192.*
spring.data.redis.lettuce.read-from=subnet:192.12.128.0/32,192.168.255.255/32
spring.data.redis.lettuce.read-from=any |
Is it ok to use /**
* Defines from which Redis nodes data is read.
*/
private ReadFrom readFrom; |
perhaps it would be beneficial to reach out to someone from the Lettuce team to explore the possibility of adding support for the At the moment: //ReadFrom valueOf(String name)
if (name.equalsIgnoreCase("subnet")) {
throw new IllegalArgumentException("subnet must be created via ReadFrom#subnet");
}
if (name.equalsIgnoreCase("regex")) {
throw new IllegalArgumentException("regex must be created via ReadFrom#regex");
}
|
I think that's a good idea. WDYT, @mp911de, about supporting |
I like the idea a lot, especially flexibility introduced with |
Thanks, @mp911de. I've opened redis/lettuce#3013 for further consideration. |
0349f8f
to
2ae3070
Compare
@wilkinsona I have the following questions:
|
I think we can use the same logic as in
I think the ones you've added are correct. |
Thank you, @philwebb |
I wonder if we should hold off on documenting |
It depends on when it gets merged :) If you think it's ready to be merged, I can remove subnet: and regex: from the metadata. |
Another approach could be to temporarily add support for |
We discussed this today and decided that we're going to err on the side of caution and wait till Lettuce 6.5 is out before merging anything. Hopefully that'll be in the Boot 3.5 timeframe. |
Thank you for your feedback, @wilkinsona. |
6.5.0.RELEASE has been released. I bumped the version to 6.5.0 and uncommented tests for |
Thanks @nosan. We're going to wait for 3.5 to merge this one. The version bump is a bit risky post RC |
Thanks, @philwebb. I know that you have a separate workflow for dependencies upgrade. So maybe, this version bump shouldn’t be included here. |
No it's fine. We'll just deal with that nearer the time. |
#42576