| 1476 | } |
| 1477 | |
| 1478 | bool redis_stream::get_one_consumer(const redis_result& rr, |
| 1479 | redis_xinfo_consumer& consumer) |
| 1480 | { |
| 1481 | if (rr.get_type() != REDIS_RESULT_ARRAY) { |
| 1482 | return false; |
| 1483 | } |
| 1484 | |
| 1485 | size_t size; |
| 1486 | const redis_result** children = rr.get_children(&size); |
| 1487 | if (children == NULL || size == 0 || size % 2 != 0) { |
| 1488 | return false; |
| 1489 | } |
| 1490 | |
| 1491 | for (size_t i = 0; i < size;) { |
| 1492 | const redis_result* first = children[i++]; |
| 1493 | if (first->get_type() != REDIS_RESULT_STRING) { |
| 1494 | i++; |
| 1495 | continue; |
| 1496 | } |
| 1497 | |
| 1498 | string value; |
| 1499 | size_t n = 0; |
| 1500 | |
| 1501 | const redis_result* second = children[i++]; |
| 1502 | redis_result_t type = second->get_type(); |
| 1503 | if (type == REDIS_RESULT_STRING) { |
| 1504 | second->argv_to_string(value); |
| 1505 | if (value.empty()) { |
| 1506 | continue; |
| 1507 | } |
| 1508 | } else if (type == REDIS_RESULT_INTEGER) { |
| 1509 | bool ok; |
| 1510 | n = (size_t) second->get_integer(&ok); |
| 1511 | if (!ok) { |
| 1512 | continue; |
| 1513 | } |
| 1514 | } else { |
| 1515 | continue; |
| 1516 | } |
| 1517 | |
| 1518 | string name; |
| 1519 | first->argv_to_string(name); |
| 1520 | |
| 1521 | if (IS_STRING(type) && EQ(name, "name")) { |
| 1522 | consumer.name = value; |
| 1523 | } else if (IS_INTEGER(type) && EQ(name, "pending")) { |
| 1524 | consumer.pending = n; |
| 1525 | } else if (IS_INTEGER(type) && EQ(name, "idle")) { |
| 1526 | consumer.idle = n; |
| 1527 | } |
| 1528 | } |
| 1529 | |
| 1530 | return !consumer.name.empty(); |
| 1531 | } |
| 1532 | |
| 1533 | bool redis_stream::xinfo_groups(const char* key, |
| 1534 | std::map<string, redis_xinfo_group>& result) |
nothing calls this directly
no test coverage detected