[Rprotobuf-yada] rpc first steps

Romain François francoisromain at free.fr
Tue Nov 17 09:31:06 CET 2009


One of the things we have not played with yet is the rcp mechanism that 
comes with protobuf. see 

I started to bring ServiceDescriptor and MethodDescriptor at the R 
level, with the classes "protobufServiceDescriptor" and 
"protobufMethodDescriptor", and added an example of a service/method in 
the example proto file:

service EchoService {
   rpc Echo (Person) returns (Person);

I also added the invokeLocally method that, well, invokes a service 
method locally, without using any rpc stuff, just to get started and to 
start thinking about how to organize this.

At the moment, it goes like this :

- You have to set the implementation of the method, which must be an R 
function that takes one argument (only requirement so far):

 > tutorial.EchoService.Echo$implementation <- function(message) message

and then you can invoke the method using invokeLocally:

 > p <- new( tutorial.Person, email = "foo at bar.com", name = "foo", id = 2 )

 > invokeLocally( tutorial.EchoService.Echo, p )$toString()
[1] "name: \"foo\"\nid: 2\nemail: \"foo at bar.com\"\n"

or, as usual:

 > tutorial.EchoService.Echo$invokeLocally( p )
[1] "name: \"foo\"\nid: 2\nemail: \"foo at bar.com\"\n"

Now the real thing is going to be the "invoke" method (not yet in) which 
will connect to another R peer, invoke the service locally and send the 
result back. for this I need to play with RpcChannel, RpcController and 
Closure, like in : 

The problem I currently have with this is that it seems to want to be 
asynchronous, which does not fit well in R.

Apart from Rserve, xGD might be an interesting starting point:


Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #50000
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc

More information about the Rprotobuf-yada mailing list