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

THREESCALE-11061: Async mode: Add support for Redis logical DBs #390

Merged
merged 3 commits into from
May 22, 2024

Conversation

jlledom
Copy link
Contributor

@jlledom jlledom commented May 21, 2024

This comes from of #350.

Now the Async mode supports Redis logical databases, and honors URLs like redis://localhost:6379/6

The support has been also added for sentinels. A typical config would look like this:

CONFIG_REDIS_PROXY=redis://redis-master/6
CONFIG_REDIS_SENTINEL_HOSTS=redis://localhost:26379,redis://localhost:26380,redis://localhost:26381

Jira: https://issues.redhat.com/browse/THREESCALE-11061

@jlledom
Copy link
Contributor Author

jlledom commented May 21, 2024

From #389 (comment):

@akostadinov

Instead of monkey patching upstream protocol class, it is a much better approach to use our own class and use the upstream protocol class with the composition pattern. Like I commented here: #350 (comment)

I don't understand what you mean. I'm not monkey patching the original protocol class, I added a new class ExtendedRESP2 which in fact is pretty similar to the example you mentioned:

https://github.com/socketry/async-redis/blob/feb67542dc27947fddbc647ad4b7289645975698/examples/auth/wrapper.rb#L52-L74

@jlledom jlledom self-assigned this May 21, 2024
@akostadinov
Copy link
Contributor

I added a new class ExtendedRESP2 which in fact is pretty similar to the example you mentioned

Because I saw you using the Async namespace, I thought this is monkey-patching the class. Could you use our own namespace for the class? It's clearer what comes from where.

# RESP2 with support for logical DBs
def make_redis_protocol(opts)
uri = URI(opts[:url] || "")
db = uri.path[1..-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking whether we need to report an error if the db is not an integer.
Or just let the client respond to select {invalid-value} with whatever it likes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wouldn't bother reraising this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @akostadinov

@jlledom
Copy link
Contributor Author

jlledom commented May 21, 2024

I added a new class ExtendedRESP2 which in fact is pretty similar to the example you mentioned

Because I saw you using the Async namespace, I thought this is monkey-patching the class. Could you use our own namespace for the class? It's clearer what comes from where.

True. Fixed in 41a9925

Copy link
Contributor

@akostadinov akostadinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It's a bummer that Redis is somehow conflicting though. I'm fine to keep it as is. One possible option is to call the module AsyncRedis for example. But I leave it to your preference.

@jlledom
Copy link
Contributor Author

jlledom commented May 22, 2024

Nice! It's a bummer that Redis is somehow conflicting though. I'm fine to keep it as is. One possible option is to call the module AsyncRedis for example. But I leave it to your preference.

Yeah, I think I'm gonna rename it.

@jlledom
Copy link
Contributor Author

jlledom commented May 22, 2024

Nice! It's a bummer that Redis is somehow conflicting though. I'm fine to keep it as is. One possible option is to call the module AsyncRedis for example. But I leave it to your preference.

Yeah, I think I'm gonna rename it.

@akostadinov done in 7a2da06

@jlledom jlledom requested review from akostadinov and mayorova May 22, 2024 10:34
@jlledom jlledom merged commit dea998b into 3scale:master May 22, 2024
2 checks passed
@mayorova mayorova mentioned this pull request Jul 3, 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
Development

Successfully merging this pull request may close these issues.

3 participants