MCPcopy Create free account
hub / github.com/acl-dev/acl / get_slot_master

Method get_slot_master

lib_acl_cpp/src/redis/redis_cluster.cpp:563–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561}
562
563redis_slot* redis_cluster::get_slot_master(const redis_result* rr)
564{
565 size_t size;
566 const redis_result** children = rr->get_children(&size);
567 if (children == NULL) {
568 return NULL;
569 }
570 if (size < 3) {
571 return NULL;
572 }
573
574 int slot_min = children[0]->get_integer();
575 if (slot_min < 0) {
576 return NULL;
577 }
578
579 int slot_max = children[1]->get_integer();
580 if (slot_max < slot_min) {
581 return NULL;
582 }
583
584 redis_slot* master = get_slot(children[2], slot_max, slot_min);
585 if (master == NULL) {
586 return NULL;
587 }
588
589 for (size_t i = 3; i < size; i++) {
590 redis_slot* slave = get_slot(children[i], slot_max, slot_min);
591 if (slave != NULL) {
592 master->add_slave(slave);
593 }
594 }
595
596 return master;
597}
598
599redis_slot* redis_cluster::get_slot(const redis_result* rr,
600 size_t slot_max, size_t slot_min)

Callers

nothing calls this directly

Calls 4

get_slotFunction · 0.50
get_childrenMethod · 0.45
get_integerMethod · 0.45
add_slaveMethod · 0.45

Tested by

no test coverage detected