Skip to content

redis请求的上下文id是怎么关联的 貌似没有找到 #128

Description

@tmacjay2015
  1. bool FiberTcpConnComplexConnector::MessageHandleFunction(const ConnectionPtr& conn, std::dequestd::any& rsp_list) {

  2. bool conn_reusable = true;

  3. for (auto&& rsp_buf : rsp_list) {

  4. ProtocolPtr rsp_protocol;
    
  5. bool ret = options_.trans_info->rsp_decode_function(std::move(rsp_buf), rsp_protocol);
    
  6. if (TRPC_LIKELY(ret)) {
    
  7.   TRPC_ASSERT(rsp_protocol);
    
  8.   conn_reusable &= rsp_protocol->IsConnectionReusable();
    
  9.   uint32_t id = 0;
    
  10.   rsp_protocol->GetRequestId(id);
    
  11.   auto ctx = call_map_->TryReclaimContext(id);   **// redis协议如何恢复这个上下文 貌似reqid再redis协议中没有透传逻辑**
    
  12.   if (TRPC_UNLIKELY(ctx.Get() == nullptr)) {
    
  13.     // The request corresponding to the response cannot be found,
    
  14.     // and the request may have timed out, so it will not be processed
    
  15.     TRPC_LOG_WARN("can not find request, request_id: " << id << ", maybe timeout");
    
  16.     continue;
    
  17. }

  18.   if (ctx->backup_request_retry_info == nullptr) {
    
  19.     ctx->rsp_msg->msg = std::move(rsp_protocol);
    
  20.     DispatchResponse(std::move(ctx));
    
  21.   } else {
    
  22.     if (!ctx->backup_request_retry_info->retry->IsReplyReady()) {
    
  23.       ctx->rsp_msg->msg = std::move(rsp_protocol);
    
  24.       DispatchResponse(std::move(ctx));
    
  25.     } else {
    
  26.       TRPC_LOG_WARN("Get response late when retry, if too many this log, consider a bigger retry delay");
    
  27.       DispatchException(std::move(ctx), TrpcRetCode::TRPC_INVOKE_UNKNOWN_ERR, "");
    
  28.     }
    
  29.   }
    
  30. } else {
    
  31.   conn_reusable = false;
    
  32.   break;
    
  33. }
    
  34. }

  35. return conn_reusable;

  36. }
    如以上代码11行的疑问 麻烦解答下 谢谢

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions