Add spring.redis.lettuce.read-from property for configuring LettuceClientConfiguration's read from setting
Currently using Lettuce but noticed that config properties lacks readFrom property and require code change to implement it, would be possible to externalize this in a property so we can override the default?
I currently have a redis sentinel totally configured by properties but I cannot configure read from property the same way.
Something like:
spring.redis.lettuce.config.read-from=REPLICA_PREFERRED
or
spring.redis.config.read-from=REPLICA_PREFERRED
Originally opened a ticket against spring data redis but was requested to open a ticket here.
Hi @nosan @wilkinsona , is there any update on this?
Hi @thiagoteichmann,
The issue is still in progress. Before moving forward, @wilkinsona reached out to the Lettuce team to request support for more complex ReadFrom types, such as regex and subnet.
I've created a PR: https://github.com/redis/lettuce/pull/3016. Once it's merged, I believe it would be possible to support this in Spring Boot as well.
However, please keep in mind that I'm just a contributor, so it would be best to wait for @wilkinsona's feedback.
Sure, no worries, thanks for the update! 👍🏻
@thiagoteichmann are you using snake_case because it is a requirement, or could you also work with kebab-case, e.g.
spring.redis.lettuce.config.read-from=replica-preferred
It would help us consider how we should implement the solution in the end greatly if we know more about your use case.
@tishun Boot's relaxed binding can take various different property formats so, personally, I wouldn't worry about handling multiple formats in Lettuce. I'd just pick one and stick with it and leave Boot to deal with that complexity.
@wilkinsona I thought that relaxed bindings only applied to property names, not values. Have I misunderstood or missed something here?
Boot can bind enums and similar in a relaxed form as well (see LenientObjectToEnumConverterFactory for example). Although we won't be targetting an enum, I think we should do something here and leave Boot to bear the burden of relaxed binding rather than Lettuce having to deal with it too.
@thiagoteichmann are you using snake_case because it is a requirement, or could you also work with kebab-case, e.g.
spring.redis.lettuce.config.read-from=replica-preferredIt would help us consider how we should implement the solution in the end greatly if we know more about your use case.
I think kebab would be clearer for me. in my case I might have reads coming from replicas instead of the default master and your sample would be an exact scenario. My original example was just copied from the enum value. :)
Closing in favor of #42588.