MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / _parse_head

Method _parse_head

dubbo/connection/connections.py:157–187  ·  view source on GitHub ↗

对dubbo响应的头部信息进行解析 :param data: :param conn: :return:

(self, data, conn)

Source from the content-addressed store, hash-verified

155 raise RuntimeError('Unknown data type {}.'.format(data_type))
156
157 def _parse_head(self, data, conn):
158 """
159 对dubbo响应的头部信息进行解析
160 :param data:
161 :param conn:
162 :return:
163 """
164 try:
165 heartbeat, body_length = parse_response_head(data)
166 except DubboResponseException as e: # 这里是dubbo的内部异常,与response中的业务异常不一样
167 logger.exception(e)
168 body_length = unpack('!i', data[12:])[0]
169 invoke_id = unpack('!q', data[4:12])[0]
170 return body_length, 2, invoke_id
171
172 if heartbeat == 2:
173 logger.debug('❤ request -> {}'.format(conn.remote_host()))
174 msg_id = data[4:12]
175 heartbeat_response = CLI_HEARTBEAT_RES_HEAD + list(msg_id) + CLI_HEARTBEAT_TAIL
176 conn.write(bytearray(heartbeat_response))
177 return body_length, 3, None if body_length > 0 else DEFAULT_READ_PARAMS
178 elif heartbeat == 1:
179 logger.debug('❤ response -> {}'.format(conn.remote_host()))
180 host = conn.remote_host()
181 self.client_heartbeats[host] -= 1
182 return body_length, 3, None if body_length > 0 else DEFAULT_READ_PARAMS
183
184 # 普通的数据包
185 else:
186 invoke_id = unpack('!q', data[4:12])[0]
187 return body_length, 3, invoke_id
188
189 def _parse_response(self, invoke_id, body):
190 """

Callers 1

_callbackMethod · 0.95

Calls 4

parse_response_headFunction · 0.90
formatMethod · 0.80
remote_hostMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected