[Rprotobuf-yada] rpc first steps

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


Hi,

One of the things we have not played with yet is the rcp mechanism that 
comes with protobuf. see 
http://code.google.com/apis/protocolbuffers/docs/proto.html#services

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 : 
http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.service.html

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:
http://www.rforge.net/xGD/

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- 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