Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python gRPC转码中允许重复字段_Python_Google Cloud Platform_Protocol Buffers_Google Cloud Endpoints_Grpc Python - Fatal编程技术网

Python gRPC转码中允许重复字段

Python gRPC转码中允许重复字段,python,google-cloud-platform,protocol-buffers,google-cloud-endpoints,grpc-python,Python,Google Cloud Platform,Protocol Buffers,Google Cloud Endpoints,Grpc Python,我在谷歌云端点中使用gRPC, 我为sayhellorerepeated添加了一个函数,但不知道如何对重复字段进行转码 helloworld.proto service Greeter { ... rpc SayHelloRepeated (RepeatedHello) returns (HelloReply) {} ... } message RepeatedHello { repeated HelloRequest hello_request = 1; } message Hello

我在谷歌云端点中使用
gRPC

我为
sayhellorerepeated
添加了一个函数,但不知道如何对重复字段进行转码

helloworld.proto

service Greeter {
...

rpc SayHelloRepeated (RepeatedHello) returns (HelloReply) {}

...
}

message RepeatedHello {
repeated HelloRequest hello_request = 1;
}

message HelloRequest {
string name = 1;
}
api\u config\u http.yaml

http:
rules:
    ...

    - selector: helloworld.Greeter.SayHelloRepeated
    get: /v1/rsayhello/{hello_request}

    ...
当我尝试部署
api\u config\u http.yaml
时,它会给我错误不允许重复字段

错误:(gcloud.endpoints.services.deploy)无效的_参数:无法转换为服务配置

种类:错误 消息:“http:不允许重复字段:通过消息“helloworld.RepeatedHello\”上的“hello\u请求”到达。”

更新

如果
HelloRequest
有多个字段,而不仅仅是一个
name
字段,该怎么办

message HelloRequest {
string name = 1;
string message = 2;
}

根据官方文件:

每个映射指定一个URL路径模板和一个HTTP方法。路径模板可以引用gRPC请求消息中的一个或多个字段,只要每个字段是具有基本(非消息)类型的非重复字段

这意味着您不能在gRPC中使用重复字段。因此,不能使用这种精确格式来使用重复字段

我建议您查看文档的这一部分,以获得有关如何执行变通方法以实现重复字段使用的更多信息


如果这些信息对你有帮助,请告诉我

嗨@Azemhaider你能看看这个案子吗?我相信它应该为您提供一些帮助,因为用户的问题似乎与您的类似,关于通过GET传递多个值。我检查了它,但它使用的是openapi.yaml。我使用的是gRPC。仍然不知道我怎样才能通过重复的字段。你能给我举个例子吗?嗨@AzemHaider,正如我在回答中提到的,不幸的是,gRPC中没有使用重复字段的方法。但是,在本文档中,您应该可以找到有关如何解决此问题的信息。你能检查一下吗?