【发布时间】:2018-06-11 22:28:02
【问题描述】:
我有一个 grpc 服务,该服务将包含 protobuf.Any 类型字段的消息作为输入,但我不知道如何为它编写正确的 json 输入。我在 GKE 上运行,云端点 ESP 和我的服务在同一个 pod 中运行。
原型看起来像:
message AnyArray {
repeated google.protobuf.Any value = 1;
}
message Metric {
string metric = 1;
int64 timestamp = 2;
double value = 3;
map<string, AnyArray> metadata = 4;
}
我为输入 json 尝试了多种组合,但没有成功,大多数时候云端点返回“原始字段不重复,无法启动列表”。失败的例子:
{
"metadata": {
"sample-key": {
"value": [1, "one"]
}
},
"metric": "request-count",
"timestamp": 1528425789,
"value": 0
}
{
"metadata": {
"sample-key": {
"value": [{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}, {
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}]
}
},
"metric": "request-count",
"timestamp": 1528425789,
"value": 0
}
来自 ESP 的响应
{
"code": 3,
"message": "metadata[0].value: Proto field is not repeating, cannot start list.",
"details": [{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "internal"
}]
}
任何帮助将不胜感激。
谢谢!
【问题讨论】: