-
Notifications
You must be signed in to change notification settings - Fork 143
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 of redis clusters #236
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this odd? It seems to suggest we are only going to care about the options from the first url that has any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the way I found to add options (password for example) without adding too much clutter.
Options other than port and host should be the same in every node (or at least we can specify only one with the redis cluster module).
If specifying multiple nodes, it will only parse the first one indeed.
Considering that only one set of options can be provided, what would be the best option in this case? We could merge all parsed url_options eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a
redis_options
parameter to the RedisClusterNamespaceManager should be the best way.Any option provided during middleware configuration gets forwarded to the cache, so like you provide the
url
you can provideredis_options
.If the concern is that it should be possible to provide options via .ini files too, there are options like decoding them from JSON when they are provided as a string instead of a dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good, will add a parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the .ini part, I'm not very fond of using another format inside a config file (like JSON inside a .ini file). What could be done is using a reference URL as
redis_cluster_options
, which will be parsed withredis.connection.parse_url
and extract options from here.But this seems as "weird" as using JSON inside a .ini file... Not sure of where to go from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at how it is done in other
ext/
files and adopted thekwargs
solution. Options are not parsed from urls anymore but are provided throughkwargs
. This seems like it's how the redis-py devs intended, and it will be more sustainable than having explicit options.