Skip to content
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 support for creating regex- and subnet-based ReadFrom instances from a single string #3013

Closed
wilkinsona opened this issue Oct 15, 2024 · 5 comments · Fixed by #3016
Closed

Comments

@wilkinsona
Copy link

Feature Request

Spring Boot would like to be able to offer support for configuring Lettuce's ReadFrom setting using an application property. This is straightforward for the many ReadFrom constants that are supported by ReadFrom#valueOf but harder for the regex and subnet variants. We'd like to make this easier by enhancing valueOf to support regex and subnet as well.

Is your feature request related to a problem? Please describe

Please see spring-projects/spring-boot#42588 for background and a description of the problem we're currently facing with trying to configure the regex and subnet variants with a single property.

Describe the solution you'd like

Our proposal is to enhance valueOf with support for a special syntax that allow the caller to indicate that a regex or subnet instance should be created and to provide the patterns or CIDR notations at the same time. The variant would be indicated by a prefix such as regex: or subnet: with the remainder of the string being the value. For example, "regex:.*region-1.*" or "subnet:192.168.0.0/16". Comma-separated values could be supported as well such as "subnet:192.168.0.0/16,2001:db8:abcd:0000::/52".

Supporting an order-sensitive regex hasn't really been considered yet. Perhaps an order-sensitive-regex would be the cleanest option?

Describe alternatives you've considered

We've considered defining this syntax in Spring Boot and pre-processing the value before calling ReadFrom#pattern or ReadFrom#subnet as appropriate. We concluded that it would be better for Lettuce itself to support the syntax as it broadens the benefit and also means that Spring Boot won't be an odd-on-out with a feature that may clash with a future change in Lettuce.

Teachability, Documentation, Adoption, Migration Strategy

Users will be able to call ReadFrom#valueOf and create any of the supported variants if they pass in an appropriately formatted string. No migration would be required as I would expect the existing subnet and regex methods to remain for those who prefer not to use a "magic" string.

@wilkinsona wilkinsona changed the title Add support for creating regex- and pattern-based ReadFrom instances from a single string Add support for creating regex- and subnet-based ReadFrom instances from a single string Oct 15, 2024
@tishun tishun added for: team-attention An issue we need to discuss as a team to make progress status: waiting-for-triage labels Oct 15, 2024
@nosan
Copy link
Contributor

nosan commented Oct 15, 2024

If you need assistance with this issue, I can create a PR. The implementation is already completed in my branch, but I'm waiting for the team's decision on whether to move forward with this enhancement.

@tishun
Copy link
Collaborator

tishun commented Oct 15, 2024

If you need assistance with this issue, I can create a PR. The implementation is already completed in my branch, but I'm waiting for the team's decision on whether to move forward with this enhancement.

PRs are welcome, especially if you already have a suggestion.

@nosan
Copy link
Contributor

nosan commented Oct 15, 2024

Would you consider adding support for the following formats as well?
ANY_REPLICA, any-replica?

nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
@nosan
Copy link
Contributor

nosan commented Oct 15, 2024

PR has been created.

nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
nosan added a commit to nosan/lettuce that referenced this issue Oct 15, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in underscore format
@tishun
Copy link
Collaborator

tishun commented Oct 16, 2024

Would you consider adding support for the following formats as well? ANY_REPLICA, any-replica?

Let's discuss this in the PR

nosan added a commit to nosan/lettuce that referenced this issue Oct 16, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in kebab-case format
nosan added a commit to nosan/lettuce that referenced this issue Oct 16, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf for subnet and regex types.
This commit introduces support for these types, as well as the use of names in snake_case, kebab-case formats
nosan added a commit to nosan/lettuce that referenced this issue Oct 16, 2024
…om a single string redis#3013

Before this commit, it was not possible to use ReadFrom.valueOf(name) for subnet and regex types.
This commit introduces a new syntax subnet:192.168.0.0/16,2001:db8:abcd:0000::/52 and regex:.*region-1.* respectively
tishun pushed a commit that referenced this issue Oct 18, 2024
…om a single string #3013 (#3016)

Before this commit, it was not possible to use ReadFrom.valueOf(name) for subnet and regex types.
This commit introduces a new syntax subnet:192.168.0.0/16,2001:db8:abcd:0000::/52 and regex:.*region-1.* respectively
@tishun tishun removed for: team-attention An issue we need to discuss as a team to make progress status: waiting-for-triage labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants