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

Function addNodeReplyForClusterSlot

src/cluster.cpp:4415–4443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4413}
4414
4415void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, int end_slot) {
4416 int i, nested_elements = 3; /* slots (2) + master addr (1) */
4417 void *nested_replylen = addReplyDeferredLen(c);
4418 addReplyLongLong(c, start_slot);
4419 addReplyLongLong(c, end_slot);
4420 addReplyArrayLen(c, 3);
4421 addReplyBulkCString(c, node->ip);
4422 /* Report non-TLS ports to non-TLS client in TLS cluster if available. */
4423 int use_pport = (g_pserver->tls_cluster &&
4424 c->conn && connGetType(c->conn) != CONN_TYPE_TLS);
4425 addReplyLongLong(c, use_pport && node->pport ? node->pport : node->port);
4426 addReplyBulkCBuffer(c, node->name, CLUSTER_NAMELEN);
4427
4428 /* Remaining nodes in reply are replicas for slot range */
4429 for (i = 0; i < node->numslaves; i++) {
4430 /* This loop is copy/pasted from clusterGenNodeDescription()
4431 * with modifications for per-slot node aggregation. */
4432 if (nodeFailed(node->slaves[i])) continue;
4433 addReplyArrayLen(c, 3);
4434 addReplyBulkCString(c, node->slaves[i]->ip);
4435 /* Report slave's non-TLS port to non-TLS client in TLS cluster */
4436 addReplyLongLong(c, (use_pport && node->slaves[i]->pport ?
4437 node->slaves[i]->pport :
4438 node->slaves[i]->port));
4439 addReplyBulkCBuffer(c, node->slaves[i]->name, CLUSTER_NAMELEN);
4440 nested_elements++;
4441 }
4442 setDeferredArrayLen(c, nested_replylen, nested_elements);
4443}
4444
4445void clusterReplyMultiBulkSlots(client * c) {
4446 /* Format: 1) 1) start slot

Callers 1

Calls 7

addReplyDeferredLenFunction · 0.85
addReplyLongLongFunction · 0.85
addReplyArrayLenFunction · 0.85
addReplyBulkCStringFunction · 0.85
connGetTypeFunction · 0.85
addReplyBulkCBufferFunction · 0.85
setDeferredArrayLenFunction · 0.85

Tested by

no test coverage detected