Serialize the consumers of a stream consumer group into the RDB. Helper * function for the stream data type serialization. What we do here is to * persist the consumer metadata, and it's PEL, for each consumer. */
| 760 | * function for the stream data type serialization. What we do here is to |
| 761 | * persist the consumer metadata, and it's PEL, for each consumer. */ |
| 762 | size_t rdbSaveStreamConsumers(rio *rdb, streamCG *cg) { |
| 763 | ssize_t n, nwritten = 0; |
| 764 | |
| 765 | /* Number of consumers in this consumer group. */ |
| 766 | if ((n = rdbSaveLen(rdb,raxSize(cg->consumers))) == -1) return -1; |
| 767 | nwritten += n; |
| 768 | |
| 769 | /* Save each consumer. */ |
| 770 | raxIterator ri; |
| 771 | raxStart(&ri,cg->consumers); |
| 772 | raxSeek(&ri,"^",NULL,0); |
| 773 | while(raxNext(&ri)) { |
| 774 | streamConsumer *consumer = ri.data; |
| 775 | |
| 776 | /* Consumer name. */ |
| 777 | if ((n = rdbSaveRawString(rdb,ri.key,ri.key_len)) == -1) { |
| 778 | raxStop(&ri); |
| 779 | return -1; |
| 780 | } |
| 781 | nwritten += n; |
| 782 | |
| 783 | /* Last seen time. */ |
| 784 | if ((n = rdbSaveMillisecondTime(rdb,consumer->seen_time)) == -1) { |
| 785 | raxStop(&ri); |
| 786 | return -1; |
| 787 | } |
| 788 | nwritten += n; |
| 789 | |
| 790 | /* Consumer PEL, without the ACKs (see last parameter of the function |
| 791 | * passed with value of 0), at loading time we'll lookup the ID |
| 792 | * in the consumer group global PEL and will put a reference in the |
| 793 | * consumer local PEL. */ |
| 794 | if ((n = rdbSaveStreamPEL(rdb,consumer->pel,0)) == -1) { |
| 795 | raxStop(&ri); |
| 796 | return -1; |
| 797 | } |
| 798 | nwritten += n; |
| 799 | } |
| 800 | raxStop(&ri); |
| 801 | return nwritten; |
| 802 | } |
| 803 | |
| 804 | /* Save a Redis object. |
| 805 | * Returns -1 on error, number of bytes written on success. */ |
no test coverage detected