TarsInvoke is used for client invoking server.
(ctx context.Context, cType byte, sFuncName string, buf []byte, status map[string]string, reqContext map[string]string, resp *requestf.ResponsePacket)
| 114 | |
| 115 | // TarsInvoke is used for client invoking server. |
| 116 | func (s *ServantProxy) TarsInvoke(ctx context.Context, cType byte, |
| 117 | sFuncName string, |
| 118 | buf []byte, |
| 119 | status map[string]string, |
| 120 | reqContext map[string]string, |
| 121 | resp *requestf.ResponsePacket) error { |
| 122 | defer CheckPanic() |
| 123 | |
| 124 | // 将ctx中的dyeing信息传入到request中 |
| 125 | var msgType int32 |
| 126 | if dyeingKey, ok := current.GetDyeingKey(ctx); ok { |
| 127 | TLOG.Debug("dyeing debug: find dyeing key:", dyeingKey) |
| 128 | if status == nil { |
| 129 | status = make(map[string]string) |
| 130 | } |
| 131 | status[current.StatusDyedKey] = dyeingKey |
| 132 | msgType |= basef.TARSMESSAGETYPEDYED |
| 133 | } |
| 134 | |
| 135 | // 将ctx中的trace信息传入到request中 |
| 136 | if trace, ok := current.GetTarsTrace(ctx); ok && trace.Call() { |
| 137 | traceKey := trace.GetTraceFullKey(false) |
| 138 | TLOG.Debug("trace debug: find trace key:", traceKey) |
| 139 | if status == nil { |
| 140 | status = make(map[string]string) |
| 141 | } |
| 142 | status[current.StatusTraceKey] = traceKey |
| 143 | msgType |= basef.TARSMESSAGETYPETRACE |
| 144 | } |
| 145 | |
| 146 | req := requestf.RequestPacket{ |
| 147 | IVersion: s.version, |
| 148 | CPacketType: int8(cType), |
| 149 | IRequestId: s.genRequestID(), |
| 150 | SServantName: s.name, |
| 151 | SFuncName: sFuncName, |
| 152 | SBuffer: tools.ByteToInt8(buf), |
| 153 | ITimeout: int32(s.timeout), |
| 154 | Context: reqContext, |
| 155 | Status: status, |
| 156 | IMessageType: msgType, |
| 157 | } |
| 158 | msg := &Message{Req: &req, Ser: s, Resp: resp} |
| 159 | msg.Init() |
| 160 | |
| 161 | if ok, hashType, hashCode, isHash := current.GetClientHash(ctx); ok { |
| 162 | msg.isHash = isHash |
| 163 | msg.hashType = HashType(hashType) |
| 164 | msg.hashCode = hashCode |
| 165 | } |
| 166 | |
| 167 | timeout := time.Duration(s.timeout) * time.Millisecond |
| 168 | if ok, to, isTimeout := current.GetClientTimeout(ctx); ok && isTimeout { |
| 169 | timeout = time.Duration(to) * time.Millisecond |
| 170 | req.ITimeout = int32(to) |
| 171 | } |
| 172 | // timeout delivery |
| 173 | if dl, ok := ctx.Deadline(); ok { |
nothing calls this directly
no test coverage detected