如何使用Python在拦截器中读取grpc proto请求?
在 PHP 中,我可以读取 $argument
,这就是我所需要的。
<?php
use Grpc\Interceptor;
class MyInterceptor extends Interceptor
{
public function interceptUnaryUnary($method,
$argument,
$deserialize,
array $metadata = [],
array $options = [],
$continuation)
{
// $argument is what I needto
return parent::interceptUnaryUnary($method, $argument, $deserialize, $metadata, $options, $continuation);
}
}
最佳答案
不幸的是,gRPC Python 没有完整的服务器拦截器实现来允许您访问 request
或 servicer_context
,但您可以访问 method
code> 字符串和 inplication_metadata
,有关更多详细信息,请查看 history 。如果你想要实现的语义可以在Python的元类或继承中实现,请这样做。如果您想请求此功能,请在 GitHub 存储库 grpc/grpc 中发布问题...
以下一些资源可能会帮助您找到答案:
关于php - python:在拦截器中读取grpc proto请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54810072/