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?

Comment From: antirez

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.

Comment From: MeirShpilraien

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?

Comment From: gkorland

@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.

Comment From: antirez

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.

Comment From: gkorland

@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.

Comment From: yossigo

Duplicate of #7992