MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterReplyMultiBulkSlots

Function clusterReplyMultiBulkSlots

src/cluster.cpp:4445–4480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4443}
4444
4445void clusterReplyMultiBulkSlots(client * c) {
4446 /* Format: 1) 1) start slot
4447 * 2) end slot
4448 * 3) 1) master IP
4449 * 2) master port
4450 * 3) node ID
4451 * 4) 1) replica IP
4452 * 2) replica port
4453 * 3) node ID
4454 * ... continued until done
4455 */
4456 clusterNode *n = NULL;
4457 int num_masters = 0, start = -1;
4458 void *slot_replylen = addReplyDeferredLen(c);
4459
4460 for (int i = 0; i <= CLUSTER_SLOTS; i++) {
4461 /* Find start node and slot id. */
4462 if (n == NULL) {
4463 if (i == CLUSTER_SLOTS) break;
4464 n = g_pserver->cluster->slots[i];
4465 start = i;
4466 continue;
4467 }
4468
4469 /* Add cluster slots info when occur different node with start
4470 * or end of slot. */
4471 if (i == CLUSTER_SLOTS || n != g_pserver->cluster->slots[i]) {
4472 addNodeReplyForClusterSlot(c, n, start, i-1);
4473 num_masters++;
4474 if (i == CLUSTER_SLOTS) break;
4475 n = g_pserver->cluster->slots[i];
4476 start = i;
4477 }
4478 }
4479 setDeferredArrayLen(c, slot_replylen, num_masters);
4480}
4481
4482void clusterCommand(client *c) {
4483 if (g_pserver->cluster_enabled == 0) {

Callers 1

clusterCommandFunction · 0.85

Calls 3

addReplyDeferredLenFunction · 0.85
setDeferredArrayLenFunction · 0.85

Tested by

no test coverage detected