spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Add spring.redis.lettuce.read-from property for configuring LettuceClientConfiguration's read from setting

Open thiagoteichmann opened this issue 1 year ago • 9 comments

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.

thiagoteichmann avatar Oct 09 '24 18:10 thiagoteichmann

Hi @nosan @wilkinsona , is there any update on this?

thiagoteichmann avatar Oct 15 '24 15:10 thiagoteichmann

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.

nosan avatar Oct 15 '24 16:10 nosan

However, please keep in mind that I'm just a contributor, so it would be best to wait for @wilkinsona's feedback.

nosan avatar Oct 15 '24 16:10 nosan

Sure, no worries, thanks for the update! 👍🏻

thiagoteichmann avatar Oct 15 '24 17:10 thiagoteichmann

@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 avatar Oct 16 '24 15:10 tishun

@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 avatar Oct 16 '24 16:10 wilkinsona

@wilkinsona I thought that relaxed bindings only applied to property names, not values. Have I misunderstood or missed something here?

nosan avatar Oct 16 '24 16:10 nosan

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.

wilkinsona avatar Oct 16 '24 17:10 wilkinsona

@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.

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

thiagoteichmann avatar Oct 16 '24 18:10 thiagoteichmann

Closing in favor of #42588.

wilkinsona avatar Oct 21 '24 15:10 wilkinsona