【发布时间】:2021-10-27 15:10:58
【问题描述】:
使用来自https://github.com/gkkachi/firestore-grpc 的 gRPC 绑定,我能够拼凑一些看似有效但没有收到任何内容的东西:
创建请求:
let req = ListenRequest {
database: format!("projects/{}/databases/(default)", project_id),
labels: HashMap::new(),
target_change: Some(TargetChange::AddTarget(Target {
// "Rust" in hex: https://github.com/googleapis/python-firestore/issues/51
target_id: 0x52757374,
once: false,
target_type: Some(TargetType::Documents(DocumentsTarget {
documents: vec![users_collection],
})),
resume_type: None,
})),
};
发送:
let mut req = Request::new(stream::iter(vec![req]));
let metadata = req.metadata_mut();
metadata.insert(
"google-cloud-resource-prefix",
MetadataValue::from_str(&db).unwrap(),
);
println!("sending request");
let res = get_client(&token).await?.listen(req).await?;
let mut res = res.into_inner();
while let Some(msg) = res.next().await {
println!("getting response");
dbg!(msg);
}
(完整代码in this repo)。
可以发出请求,但流不包含任何实际内容。我从调试日志中得到的唯一提示是
[2021-10-27T14:54:39Z DEBUG h2::codec::framed_write] send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
[2021-10-27T14:54:39Z DEBUG h2::proto::connection] Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
知道缺少什么吗?
【问题讨论】:
-
我将尝试复制。您是否尝试过使用另一个 gRPC 客户端,例如
gRPCurl测试你的配置? -
谢谢,我会试试的。我提供的要点需要一些额外的东西来重现。为了更容易,我创建了github.com/rksm/firestore-streaming-test-rs。它应该只需要一个服务帐户凭据,然后应该能够按原样运行。
-
这是一个黑匣子,不是吗?我的 Rust foo 很弱,但我熟悉 Google 的库。我实际上并没有使用过 Firestore 监听器,例如去吧,这对我来说是新的领域。很高兴知道是否有人曾经让这个工作。在要点中,您在使用
collection_id时遇到问题吗?"users".into()?您提供的是完全合格的路径 -
select: None和r@where: None也建议不要查询我们观察到的任何内容。没有结果。 -
我添加了一个
Projection,现在我是getting response,只是Unknown(缺少gprc-status 标头,映射自HTTP 状态码200`(200 不会是坏的) ) 但是,我不明白为什么:-)
标签: firebase google-cloud-firestore rust grpc