gRPC连接的两端都可以接受方法调用吗? [英] Can both ends of a gRPC connection accept method calls?

查看:90
本文介绍了gRPC连接的两端都可以接受方法调用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于gRPC的介绍:

在gRPC中, client 应用程序可以直接在其他计算机上的 server 应用程序上调用方法,就好像它是本地对象一样,使您更轻松地创建分布式应用程序和服务.在许多RPC系统中,gRPC都基于定义 service 的思想,该规范指定可以使用其参数和返回类型远程调用的方法.在服务器端,服务器实现此接口并运行gRPC服务器以处理客户端调用.在客户端,客户端具有一个 stub ,它提供与服务器完全相同的方法.

In gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub that provides exactly the same methods as the server.

以上段落讨论了客户端和服务器,前者是调用方法的服务器.我想知道的是:连接的服务器端是否可以调用已在客户端上注册的方法?

The above paragraph talks about a client and a server, with the former being the one who is invoking methods to the other. What am I wondering is: can the server-end of the connection invoke methods that have been registered on the client?

推荐答案

否,服务器无法在客户端上调用呼叫. gRPC使用 HTTP,并且HTTP过去没有这种语义.

No, a server cannot invoke calls on the client. gRPC works with HTTP, and HTTP has not had such semantics in the past.

关于实现此功能的各种方法已经进行了讨论,但是我不知道在设计上已经开始的任何工作或未达成普遍协议. gRPC确实支持双向流传输,这可能会为您带来一些所需的东西.通过双向流传输,客户端可以响应来自服务器的消息,但是客户端仍在呼叫服务器,并且只能为该呼叫发送一种消息.

There has been discussion as to various ways to achieve such a feature, but I'm unaware of any work having started or general agreement on a design. gRPC does support bidirectional streaming, which may get you some of what you need. With bidirectional streaming the client can respond to messages from server, but the client still calls the server and only one type of message can be sent for that call.

这篇关于gRPC连接的两端都可以接受方法调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆