Rust 如何从gRPC功能使用超级客户端?
我有一个gRPC服务器,需要进行HTTP GET。我正努力在电话中找到正确的未来 我在试这个Rust 如何从gRPC功能使用超级客户端?,rust,hyper,Rust,Hyper,我有一个gRPC服务器,需要进行HTTP GET。我正努力在电话中找到正确的未来 我在试这个 fn current( &self, _: ::grpc::RequestOptions, p: quote::CurrentRequest, ) -> ::grpc::SingleResponse<quote::CurrentResponse> { let symbol = p.get_symbol(); let client = C
fn current(
&self,
_: ::grpc::RequestOptions,
p: quote::CurrentRequest,
) -> ::grpc::SingleResponse<quote::CurrentResponse> {
let symbol = p.get_symbol();
let client = Client::new();
let fut: grpc::GrpcFuture<quote::CurrentResponse> = Box::new(
client
.get(Uri::from_static(AlphaFunction::base_url()))
.and_then(|res| res.into_body().concat2())
.and_then(|body| {
info!("body {:?}", body);
let mut r = quote::CurrentResponse::new();
// TODO: Parse body
r.set_symbol(symbol.to_string());
Ok(r)
})
.map_err(|e| e),
);
grpc::SingleResponse::new(fut)
}
及
77 | grpc::SingleResponse::new(fut)
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^所需的结构“proto
我想出来了:
let fut = client
.get(Uri::from_static(AlphaFunction::base_url()))
.and_then(|res| res.into_body().concat2())
.and_then(move |body| {
info!("body {:?}", body);
let mut r = quote::CurrentResponse::new();
r.set_symbol(symbol.to_string());
Ok(r)
})
.map_err(|e| grpc::Error::Panic(format!("{}", e)));
很难回答你的问题,因为它没有包含一个。我们无法说出代码中存在哪些板条箱(及其版本)、类型、特征、字段等。如果您试图重现您的错误(如果可能的话),或者在全新的货运项目中,那么我们将更容易帮助您,然后您的问题将包括附加信息。您可以使用以下方法减少在此处发布的原始代码。谢谢吸取教训,谢谢!没有任何文字来描述这些变化是什么以及为什么需要这些变化的答案,对那些试图在事后使用它们的人来说,帮助微乎其微。