| 876 | } |
| 877 | |
| 878 | comm::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 | |
| 923 | void Consumer::CheckMaxLoop(const int vpid) { |
| 924 | comm::RetCode ret; |
nothing calls this directly
no test coverage detected