Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can both ends of a gRPC connection accept method calls?

Tags:

grpc

From the introduction on gRPC:

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?

like image 708
Tim Cooper Avatar asked May 02 '15 23:05

Tim Cooper


People also ask

How is gRPC bidirectional?

gRPC supports streaming semantics, where either the client or the server (or both) send a stream of messages on a single RPC call. The most general case is Bidirectional Streaming where a single gRPC call establishes a stream in which both the client and the server can send a stream of messages to each other.

Can gRPC handle multiple clients?

Multiple gRPC clients can be created from a channel, including different types of clients. A channel and clients created from the channel can safely be used by multiple threads. Clients created from the channel can make multiple simultaneous calls.

How does gRPC connection work?

A gRPC channel provides a connection to a gRPC server on a specified host and port. It is used when creating a client stub. Clients can specify channel arguments to modify gRPC's default behavior, such as switching message compression on or off. A channel has state, including connected and idle .

Is gRPC full duplex?

gRPC supports duplex communications by means of streams. We can mark either a request or a response as a stream and can write/read from the stream until it is closed.


1 Answers

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

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.

like image 62
Eric Anderson Avatar answered Sep 24 '22 22:09

Eric Anderson