-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
support json() +with pipeline in asyncio.cluster mode #2423
Conversation
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.
I think you don't need any changes to cluster.py except for adding AsyncRedisModuleCommands inheritance to the RedisCluster & ClusterPipeline classes.
@@ -298,7 +300,10 @@ def __init__( | |||
# Call our on_connect function to configure READONLY mode | |||
kwargs["redis_connect_func"] = self.on_connect | |||
|
|||
kwargs["response_callbacks"] = self.__class__.RESPONSE_CALLBACKS.copy() | |||
kwargs["cluster_response_callbacks"] = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS) |
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.
What is the purpose of renaming this variable? Also, what is the advantage of using CaseInsensitiveDict? It is significantly slower that a normal dict due to the case conversion for each call.
@@ -1206,7 +1211,7 @@ async def close(self, attr: str = "nodes_cache") -> None: | |||
) | |||
|
|||
|
|||
class ClusterPipeline(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommands): | |||
class ClusterPipeline(RedisCluster): |
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.
Why are the bases for this class changed? Inheriting directly from the RedisCluster class could lead to collisions in the namespace
def __init__( | ||
self, | ||
client: RedisCluster, | ||
nodes_manager=None, |
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.
The new kwargs are not used anywhere?
@@ -298,7 +300,10 @@ def __init__( | |||
# Call our on_connect function to configure READONLY mode | |||
kwargs["redis_connect_func"] = self.on_connect | |||
|
|||
kwargs["response_callbacks"] = self.__class__.RESPONSE_CALLBACKS.copy() | |||
kwargs["cluster_response_callbacks"] = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS) | |||
self.cluster_response_callbacks = CaseInsensitiveDict( |
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 will always get overwritten on line 332.
self._client = client | ||
|
||
self.cluster_response_callbacks = self.RESPONSE_CALLBACKS |
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 not used anywhere?
@@ -152,6 +153,7 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommand | |||
- none of the `host`/`port` & `startup_nodes` were provided | |||
|
|||
""" | |||
response_callbacks: MutableMapping[Union[str, bytes], ResponseCallbackT] |
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 defined but never initialized?
@utkarshgupta137 I was hopping you would check this out and provide pointers or improvements. As said, i'm really inexperienced with all this and hoped to help out.. but i was really struggling by comparing sync cluster, pipeline and json() with the current implemented async code, so just started copying stuff, run it, and patching the next exception in any way I could think of, till I got it working and then I was drained and confused by how things got to the point where it started to work ;-) |
I've reverted quite some changes and took your recommendations resulting in: set_response_callback() was used before from inheriting RedisCluster.. ps. also, when I removed RedisCluster from ClusterPipeline's inheritance the json_init_.py is not accepting the parameters in AsyncioClusterPipeline() anymore at line 178 KR |
I've never used any redis modules, so I can't work on this myself. I can review cluster related code though. For now, I would recommend not changing anything in the cluster.py file except adding inheritance for async redis modules command to the client & pipeline classes. |
If you've docker running somewhere you could run a redis cluster with modules using: Then you can use the test.py that i've added in the example dir once you've made and build changes. note. running the redis-cluster with modules makes my NVME drive make wierd sounds and memory availability limited |
This pull request is marked stale. It will be closed in 30 days if it is not updated. |
Pull Request check-list
Please make sure to review and check all of these items:
$ tox
pass with this change (including linting)?NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
Please provide a description of the change here.
Hi, as newbie redis-user I ran into #2234 with asyncio cluster support for json() + also in combination with pipelines
I've created some patches, that resulted in functioning support for this.
As i'm not practiced enough with big projects like these, I would like to request someone to review the changes that I've made. I might have broken some other things (or not), and I'm sure there are some rookie mistakes in the changes.. but it works for me.. and I've spent quite some hours on this.
So I hope someone who's more experienced could help pickup my improvements for the project, and improve upon it.
I'm guessing there also needs a bit of testing to get extended.
I unfortunately have no resources to complete that, and run the complete set op tests, and to investigate the results.
I've ran my test.py (see examples/) using python3.10.4 and the docker image redis-modcluster and that works fine for my usecase (looking from the surface, in my brief tests), I unfortunately have to carry-on doing other stuff.
Thanks in advance!