php - python:在拦截器中读取grpc proto请求

标签 php python protocol-buffers grpc

如何使用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 没有完整的服务器拦截器实现来允许您访问 requestservicer_context,但您可以访问 method code> 字符串和 inplication_metadata,有关更多详细信息,请查看 history 。如果你想要实现的语义可以在Python的元类或继承中实现,请这样做。如果您想请求此功能,请在 GitHub 存储库 grpc/grpc 中发布问题...

以下一些资源可能会帮助您找到答案:

关于php - python:在拦截器中读取grpc proto请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54810072/

相关文章:

javascript - Javascript 代码中的这个 If 条件有什么问题吗?

PHP 尝试连接 SQLite3 时返回 PDOException 'could not find driver'

php - 从 PHP 脚本执行 ffmpeg 命令

python - 导入错误 : No module named base

python - 将二进制文件转换为 proto 文件

php - 在 Phalcon Framework 的方法 find() 的条件下传递变量

python - 大于二维数组中某个值的最小相邻单元格的索引

python - 为什么Python的格式函数中的 `=`会在前缀后插入填充?

c++ - 为什么预构建的 Protocol Buffer 不包含任何头文件

c++ - 在protobuf中,copyFrom优先于赋值吗?