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

Method Handle

phxqueue/consumer/consumer.cpp:878–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876}
877
878comm::RetCode Consumer::Handle(const comm::proto::ConsumerContext &cc,
879 comm::proto::QItem &item, comm::HandleResult &handle_result) {
880
881 comm::ConsumerConsumeBP::GetThreadInstance()->OnHandle(impl_->cc, item);
882
883 comm::RetCode ret;
884
885 RestoreUserCookies(item.meta().user_cookies());
886
887 std::string uncompressed_buffer;
888 if (comm::RetCode::RET_OK != (ret = UncompressBuffer(item.buffer(), item.buffer_type(), uncompressed_buffer))) {
889 QLErr("DecodeBuffer ret %d", comm::as_integer(ret));
890 handle_result = comm::HandleResult::RES_ERROR;
891 return ret;
892 }
893
894 auto &&handler = GetHandler(item.meta().handle_id());
895 if (!handler) {
896 QLErr("GetHandler return null handle_id %d", item.meta().handle_id());
897 handle_result = comm::HandleResult::RES_ERROR;
898 return comm::RetCode::RET_ERR_RANGE_HANDLE;
899 }
900
901 handle_result = handler->Handle(cc, item, uncompressed_buffer);
902 QLVerb("handle_result %d handle->IsBufferUpdated() %d", static_cast<int>(handle_result), handler->IsBufferUpdated());
903
904 if (handler->IsBufferUpdated()) {
905 CompressBuffer(uncompressed_buffer, *item.mutable_buffer(), item.buffer_type());
906 }
907
908 comm::ConsumerConsumeBP::GetThreadInstance()->OnHandleEnd(impl_->cc, item, handle_result);
909
910 auto &&client_id = item.meta().client_id();
911 if (client_id.empty()) {
912 QLVerb("Handle handle_id %d ori_pub_id %d pub_id %d sub_ids %" PRIu64 " hash %" PRIu64 " uin %" PRIu64 " handle_result %d",
913 item.meta().handle_id(), item.meta().pub_id(), item.pub_id(), (uint64_t)item.sub_ids(), (uint64_t)item.meta().hash(), (uint64_t)item.meta().uin(), handle_result);
914 } else {
915 QLInfo("Handle handle_id %d ori_pub_id %d pub_id %d sub_ids %" PRIu64 " hash %" PRIu64 " uin %" PRIu64 " handle_result %d client_id %s",
916 item.meta().handle_id(), item.meta().pub_id(), item.pub_id(), (uint64_t)item.sub_ids(), (uint64_t)item.meta().hash(), (uint64_t)item.meta().uin(), handle_result,
917 client_id.c_str());
918 }
919
920 return comm::RetCode::RET_OK;
921}
922
923void Consumer::CheckMaxLoop(const int vpid) {
924 comm::RetCode ret;

Callers

nothing calls this directly

Calls 4

as_integerFunction · 0.85
OnHandleMethod · 0.80
IsBufferUpdatedMethod · 0.80
OnHandleEndMethod · 0.80

Tested by

no test coverage detected