-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add rpc proxy client #336
add rpc proxy client #336
Conversation
\Hyperf\RpcClient\Pool\RpcClientPool 这个看上去没有用,transporter 是每次创建新对象,没有使用对象池,是不是要删除? |
最后就只剩下一个问题了。。那就是生成的 代理 Client,没有办法被 AOP 切入。。 |
刚刚把 ServiceClient 创建使用 make 函数创建,如果需要可以替换对应的实现或者加 AOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@limingxinleo 除了最后的那个 conversation 就是 if 的合并,我没有其它问题了,你看看
@wenbinye 关于 RPC 的代理客户端,还需要补充一下文档的内容,文档可以在另一个 PR,然后关联一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最后一个 commit,看一下,应该是没问题的。。
protected function __request(string $method, array $params, ?string $id = null)
{
if ($this->idGenerator instanceof IdGeneratorInterface && ! $id) {
$id = $this->idGenerator->generate();
}
$response = $this->client->send($this->__generateData($method, $params, $id));
if (! is_array($response)) {
throw new RequestException('Invalid response.');
}
if (isset($response['result'])) {
$type = $this->methodDefinitionCollector->getReturnType($this->serviceName, $method);
return $this->normalizer->denormalize($response['result'], $type->getName());
}
if ($code = $response['error']['code'] ?? null) {
$error = $response['error'];
// Denormalize exception.
$class = Arr::get($error, 'data.class');
$attributes = Arr::get($error, 'data.attributes', []);
if (isset($class) && class_exists($class) && $e = $this->normalizer->denormalize($attributes, $class)) {
if ($e instanceof \Exception) {
throw $e;
}
}
// Throw RequestException when denormalize exception failed.
throw new RequestException($error['message'] ?? '', $error['code']);
}
throw new RequestException('Invalid response.');
} @huangzhhui @wenbinye 最后再 review 一下看看。。 |
使用 ast 生成代理类调用 rpc 服务
fix #306