MCPcopy Create free account
hub / github.com/F-Stack/f-stack / RM_SendClusterMessage

Function RM_SendClusterMessage

app/redis-6.2.6/src/module.c:6076–6083  ·  view source on GitHub ↗

Send a message to all the nodes in the cluster if `target` is NULL, otherwise * at the specified target, which is a REDISMODULE_NODE_ID_LEN bytes node ID, as * returned by the receiver callback or by the nodes iteration functions. * * The function returns REDISMODULE_OK if the message was successfully sent, * otherwise if the node is not connected or such node ID does not map to any * known

Source from the content-addressed store, hash-verified

6074 * otherwise if the node is not connected or such node ID does not map to any
6075 * known cluster node, REDISMODULE_ERR is returned. */
6076int RM_SendClusterMessage(RedisModuleCtx *ctx, char *target_id, uint8_t type, unsigned char *msg, uint32_t len) {
6077 if (!server.cluster_enabled) return REDISMODULE_ERR;
6078 uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0);
6079 if (clusterSendModuleMessageToTarget(target_id,module_id,type,msg,len) == C_OK)
6080 return REDISMODULE_OK;
6081 else
6082 return REDISMODULE_ERR;
6083}
6084
6085/* Return an array of string pointers, each string pointer points to a cluster
6086 * node ID of exactly REDISMODULE_NODE_ID_SIZE bytes (without any null term).

Callers

nothing calls this directly

Calls 2

moduleTypeEncodeIdFunction · 0.85

Tested by

no test coverage detected