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 JSON commands in Async Cluster #2234

Closed
motybz opened this issue Jun 15, 2022 · 6 comments · Fixed by #3115
Closed

Add support for JSON commands in Async Cluster #2234

motybz opened this issue Jun 15, 2022 · 6 comments · Fixed by #3115
Assignees

Comments

@motybz
Copy link

motybz commented Jun 15, 2022

It seems that the .json() ability is supported in the Cluster client but not in Async Cluster client.

from redis.asyncio.cluster import RedisCluster
client = RedisCluster()
await client.json().get("test")

AttributeError: 'RedisCluster' object has no attribute 'json'

@chayim
Copy link
Contributor

chayim commented Dec 13, 2022

Supported in 4.4.0.

@baltika10
Copy link

This doesn't seem to work still
AttributeError: 'RedisCluster' object has no attribute 'json'
when using redis.asyncio.cluster.RedisCluster (version 4.5.1)

@chayim
Copy link
Contributor

chayim commented Mar 2, 2023

@dvora-h can you double check this?

@bharatbots
Copy link

This still doesn't work with redis.asyncio. I'm using the latest version(4.5.5)

@the-wondersmith
Copy link

@chayim I can confirm @bharatbots's findings, FWIW

@the-wondersmith
Copy link

@chayim @bharatbots

Did some more digging / testing. Long story short, the comments in PR #2423 are correct - redis.commands.redismodules.AsyncRedisModuleCommands needs to be added to the inherited classes for redis.asyncio.cluster.RedisCluster and redis.asyncio.cluster.ClusterPipeline.

ALSO, an implementation of set_response_callback needs to be added to the cluster pipeline class that propagates the supplied callback to the bound client's associated Node's.

From my testing, this seems to work just fine:

def set_response_callback(self, command: str, callback: Callable[..., Any]) -> None:
    """Set a custom response callback."""
    self._client.set_response_callback(command, callback)

    for node in self._client.nodes_manager.nodes_cache.values():
        node.response_callbacks[command] = callback

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 a pull request may close this issue.

6 participants