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

Calling RedisModule_Call using ctx with fake client #5384

Open
MeirShpilraien opened this issue Sep 25, 2018 · 6 comments
Open

Calling RedisModule_Call using ctx with fake client #5384

MeirShpilraien opened this issue Sep 25, 2018 · 6 comments

Comments

@MeirShpilraien
Copy link
Collaborator

We are trying to create a module that works on oss cluster. The module send some commands to invoke on all the servers and then perform some aggregations to the results. We decided to use the experimental cluster api to send the commands to all the server and invoke them using RedisModule_Call.

The issue is that on RedisModuleClusterMessageReceiver callback we only have a RedisModuleCtx with a fake client and the command we are trying to invoke is blocking the client (RedisModule_BlockClient), So we ends up receiving a NULL reply (and I am not even sure its ok to call a command that blocks the client via RedisModule_Call with a fake client ctx).

Is there a way to use RedisModule_Call asynchronously by passing a callback to be called when the command is done?

Any other idea how to deal with this issue?

@antirez
Copy link
Contributor

antirez commented Sep 25, 2018

Hello @MeirShpilraien, the reason why you see NULL returned is because calling a blocking command via RedisModule_Call() is invalid. What is your goal? You may probably use the key notification API in order to perform certain operations only when some key received a write.

@MeirShpilraien
Copy link
Collaborator Author

Hey,
I am trying to call a module command which perform blocking. Isn't there any way to perform the RedisModule_Call asynchronously and provide a callback?

@gkorland
Copy link
Contributor

@antirez we're trying to build a generic module that calls RedisModule_Call according to the user input.
The problem is that the command called is another module blocking command, which in his turn has no awareness that it was being called by RedisModule_Call and not by a remote client.

@antirez
Copy link
Contributor

antirez commented Sep 26, 2018

Understood: the module Call() interface is synchronous, there is no way to make it async: you can traslate the async call to its sync counterpart (like BRPOP -> RPOP), and if it returns no elements register an event or alike, or return an error to the user.

@gkorland
Copy link
Contributor

@antirez I don't see how it can be done especially in case where module command called is using the new Cluster Messaging API and has to wait for other shards to response.

@yossigo
Copy link
Member

yossigo commented Nov 24, 2020

Duplicate of #7992

@yossigo yossigo marked this as a duplicate of #7992 Nov 24, 2020
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

No branches or pull requests

4 participants