Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protobuf RPC callbacks

Is there any way to do the invoke call from server to the client with Protobuf RPC(while custom call from client to the server, not directly)?

I'm meaning, for example, describe service method in *.proto file with callback param?

Im using gRPC library.

like image 457
Alexandr Derkach Avatar asked Feb 26 '16 09:02

Alexandr Derkach


People also ask

What is callback in gRPC?

grpc::Server::GlobalCallbacks Class Referenceabstract. Global callbacks are a set of hooks that are called when server events occur.

What is the difference between RPC and gRPC?

It is an adaptation of traditional RPC frameworks. So what makes it different from the existing RPC frameworks? The most important difference is that gRPC uses protocol buffers as the interface definition language for serialization and communication instead of JSON/XML.

Can gRPC server 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.

Is gRPC synchronous or asynchronous?

The gRPC programming API in most languages comes in both synchronous and asynchronous flavors. You can find out more in each language's tutorial and reference documentation (complete reference docs are coming soon).


1 Answers

The general way to do server->client messages in gRPC is through "streaming". That is, the client makes a call to the server, and then the server can "stream" back a series of messages to the client before eventually completing the call.

See: http://www.grpc.io/docs/guides/concepts.html#server-streaming-rpc

Of course, "streaming" is a pretty different pattern from a traditional "callback", but you can often solve the same problems with it.

Note that Cap'n Proto RPC -- an alternative to Protobuf and gRPC -- fully supports calls in both directions by virtue of supporting object references as a first-class type: a client can, for example, make a call to the server in which it provides an object reference to use for callbacks, and then the server can later on make calls back to that object on the client.

(Disclosure: I am the author of Google's Protobuf v2 and also the author of Cap'n Proto, but I am not affiliated with gRPC.)

like image 162
Kenton Varda Avatar answered Sep 29 '22 23:09

Kenton Varda