MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Consume

Method Consume

phxqueue/consumer/consumer.cpp:840–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840comm::RetCode Consumer::Consume(const comm::proto::ConsumerContext &cc,
841 const vector<shared_ptr<comm::proto::QItem> > &items,
842 vector<comm::HandleResult> &handle_results) {
843 comm::ConsumerBP::GetThreadInstance()->OnConsume(cc, items);
844
845 handle_results.clear();
846 for (int i{0}; i < items.size(); ++i) {
847 handle_results.push_back(comm::HandleResult::RES_ERROR);
848 }
849
850 {
851 int iret = 0;
852
853 while (sizeof(char) != (iret = write(impl_->consume_fds[0], "a", sizeof(char)))) {
854 QLErr("write ret %d err %s", iret, strerror(errno));
855 poll(nullptr, 0, 100);
856 }
857
858
859 char ch;
860 while (sizeof(char) != (iret = read(impl_->consume_fds[0], &ch, sizeof(char)))) {
861 QLErr("read ret %d err %s", iret, strerror(errno));
862 poll(nullptr, 0, 100);
863 }
864 }
865
866 comm::ConsumerBP::GetThreadInstance()->OnConsumeSucc(cc, items, handle_results);
867
868 impl_->freq.UpdateConsumeStat(impl_->vpid, cc, items);
869
870 return comm::RetCode::RET_OK;
871}
872
873bool Consumer::SkipHandle(const comm::proto::ConsumerContext &cc, const comm::proto::QItem &item) {
874 if (!(item.sub_ids() & (1ULL << (cc.sub_id() - 1)))) return true;

Callers

nothing calls this directly

Calls 3

OnConsumeMethod · 0.80
OnConsumeSuccMethod · 0.80
UpdateConsumeStatMethod · 0.80

Tested by

no test coverage detected