本文介绍了gRPC与节点应用程序中的同步调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现多个gRPC服务器的应用程序.客户端是在nodeJS中实现的.客户端一个接一个地调用多个gRPC调用.由于在nodeJS中,通道是根据ServiceClient创建的,因此如何确保在调用第二个gRPC调用之前完成第一个gRPC调用.

I have an application which implements multiple gRPC servers.The client side is implemented in nodeJS.The client invokes multiple gRPC calls one after another.Since in nodeJS, channel is created per ServiceClient , how to ensure that the first gRPC call is complete before the second gRPC call is invoked.

是否可以将多个ServiceClient指定为对所有通信使用同一通道?

Is there a way to specify multiple ServiceClient to use same channel for all the communication ?

是否可以在nodeJS中使用同步gRPC调用?

Is there a way to use synchronous gRPC calls in nodeJS ?

推荐答案

节点gRPC没有同步调用.与任何异步Node操作一样,您可以通过在第一个调用的完成回调中调用第二个调用来确保按顺序进行两个调用.

Node gRPC does not have synchronous calls. As with any asynchronous Node operation, you can ensure that two calls are made sequentially by invoking the second one in the completion callback of the first.

不,目前还没有一个API可以让多个客户端对象使用同一通道.

And no, there is not currently an API to have multiple client objects use the same channel.

这篇关于gRPC与节点应用程序中的同步调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:16