user270398
user270398

Reputation: 451

callback in protobuffers implementation -?

Is there some way to define callback rpc procedure in proto syntax? I am trying to define RPC call to start data processing process/loop on RPC server that would write results back to RPC client asynchronously... Any ideas? Thanks

Upvotes: 1

Views: 1836

Answers (2)

Kenton Varda
Kenton Varda

Reputation: 45286

This is a very reasonable thing to want, but a surprisingly difficult thing for an RPC implementation to provide. Once you have the ability to introduce new call endpoints at runtime, you need a way to garbage collect them, you need latency compensation (so that when a method returns a reference to another callable object, the client can start sending calls to it without waiting for a network round trip), and you potentially need ways to pass objects on to other machines in a network without proxying. Almost no protocols implement all these things -- CapTP is the only one I know of, and it's tied to an obscure programming language.

Due to the complication, Protocol Buffers never supported this in a general way. Individual Protobuf-based RPC systems might contain special-cases for certain use cases, such as a server "streaming" multiple messages back in response to a single call. But, the .proto language syntax has no particular way of expressing anything other than simple method calls on singleton objects where the client is strictly the caller.

FWIW, I am currently working on a new alternative which has the features of CapTP but the practicality of Protocol Buffers, called Cap'n Proto. However, the RPC implementation is still a few months away. (I was also the author of Protocol Buffers v2.)

Upvotes: 2

pjklauser
pjklauser

Reputation: 1156

If you're in the java world, you can use the https://code.google.com/p/protobuf-rpc-pro/ library to define a RPC service on both sides of the "connection" - and do reverse RPC back from server to client. In the standard google protobuf RPC interface there is no provision to get data back to a client which is not in the RPC response.

Upvotes: 0

Related Questions