| 1569 | } |
| 1570 | |
| 1571 | bool redis_stream::get_one_group(const redis_result& rr, |
| 1572 | redis_xinfo_group& group) |
| 1573 | { |
| 1574 | if (rr.get_type() != REDIS_RESULT_ARRAY) { |
| 1575 | return false; |
| 1576 | } |
| 1577 | |
| 1578 | size_t size; |
| 1579 | const redis_result** children = rr.get_children(&size); |
| 1580 | if (children == NULL || size == 0 || size % 2 != 0) { |
| 1581 | return false; |
| 1582 | } |
| 1583 | |
| 1584 | for (size_t i = 0; i < size;) { |
| 1585 | const redis_result* first = children[i++]; |
| 1586 | if (first->get_type() != REDIS_RESULT_STRING) { |
| 1587 | i++; |
| 1588 | continue; |
| 1589 | } |
| 1590 | |
| 1591 | string value; |
| 1592 | size_t n = 0; |
| 1593 | |
| 1594 | const redis_result* second = children[i++]; |
| 1595 | redis_result_t type = second->get_type(); |
| 1596 | if (type == REDIS_RESULT_STRING) { |
| 1597 | second->argv_to_string(value); |
| 1598 | if (value.empty()) { |
| 1599 | continue; |
| 1600 | } |
| 1601 | } else if (type == REDIS_RESULT_INTEGER) { |
| 1602 | bool ok; |
| 1603 | n = (size_t) second->get_integer(&ok); |
| 1604 | if (!ok) { |
| 1605 | continue; |
| 1606 | } |
| 1607 | } else { |
| 1608 | continue; |
| 1609 | } |
| 1610 | |
| 1611 | string name; |
| 1612 | first->argv_to_string(name); |
| 1613 | |
| 1614 | if (IS_STRING(type) && EQ(name, "name")) { |
| 1615 | group.name = value; |
| 1616 | } else if (IS_INTEGER(type) && EQ(name, "consumers")) { |
| 1617 | group.consumers = n; |
| 1618 | } else if (IS_INTEGER(type) && EQ(name, "pending")) { |
| 1619 | group.pending = n; |
| 1620 | } else if (IS_STRING(type) && EQ(name, "last-delivered-id")) { |
| 1621 | group.last_delivered_id = value; |
| 1622 | } |
| 1623 | } |
| 1624 | |
| 1625 | return !group.name.empty(); |
| 1626 | } |
| 1627 | |
| 1628 | bool redis_stream::xinfo_stream(const char* key, redis_stream_info& info) |
nothing calls this directly
no test coverage detected