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

Function addNodeReplyForClusterSlot

app/redis-6.2.6/src/cluster.c:4356–4384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4354}
4355
4356void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, int end_slot) {
4357 int i, nested_elements = 3; /* slots (2) + master addr (1) */
4358 void *nested_replylen = addReplyDeferredLen(c);
4359 addReplyLongLong(c, start_slot);
4360 addReplyLongLong(c, end_slot);
4361 addReplyArrayLen(c, 3);
4362 addReplyBulkCString(c, node->ip);
4363 /* Report non-TLS ports to non-TLS client in TLS cluster if available. */
4364 int use_pport = (server.tls_cluster &&
4365 c->conn && connGetType(c->conn) != CONN_TYPE_TLS);
4366 addReplyLongLong(c, use_pport && node->pport ? node->pport : node->port);
4367 addReplyBulkCBuffer(c, node->name, CLUSTER_NAMELEN);
4368
4369 /* Remaining nodes in reply are replicas for slot range */
4370 for (i = 0; i < node->numslaves; i++) {
4371 /* This loop is copy/pasted from clusterGenNodeDescription()
4372 * with modifications for per-slot node aggregation. */
4373 if (nodeFailed(node->slaves[i])) continue;
4374 addReplyArrayLen(c, 3);
4375 addReplyBulkCString(c, node->slaves[i]->ip);
4376 /* Report slave's non-TLS port to non-TLS client in TLS cluster */
4377 addReplyLongLong(c, (use_pport && node->slaves[i]->pport ?
4378 node->slaves[i]->pport :
4379 node->slaves[i]->port));
4380 addReplyBulkCBuffer(c, node->slaves[i]->name, CLUSTER_NAMELEN);
4381 nested_elements++;
4382 }
4383 setDeferredArrayLen(c, nested_replylen, nested_elements);
4384}
4385
4386void clusterReplyMultiBulkSlots(client * c) {
4387 /* 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