24 const absl::StatusOr<std::string> created = redis_.Command(
27 !absl::StrContains(created.status().message(),
"BUSYGROUP")) {
28 return created.status();
34 std::vector<std::string> words = {
"XREADGROUP",
"GROUP",
kGroup, consumer_};
35 words.insert(words.end(), {
"COUNT", std::to_string(kBatch)});
37 words.insert(words.end(), {
"BLOCK", std::to_string(wait_.count())});
39 words.insert(words.end(), {
"STREAMS", kEventStream, pending_ ?
"0" :
">"});
40 const absl::StatusOr<std::vector<Redis::Entry>> entries = redis_.Read(words);
42 return entries.status();
44 if (entries->empty()) {
52 for (std::size_t i = 0; i + 1 < entry.fields.size(); i += 2) {
53 if (entry.fields[i] ==
"row") {
54 rows += entry.fields[i + 1];
58 ack.push_back(entry.id);
61 const absl::Status stored = sink_(rows);
68 const absl::StatusOr<std::string> acked = redis_.Command(ack);
70 return acked.status();
72 return static_cast<int>(entries->size());
Recorder(Redis &redis, std::string consumer, Sink sink, std::chrono::milliseconds wait=std::chrono::seconds(1))
Waits up to wait each time for events to come, as the consumer.