ThriftR is a pure R implementation of Apache Thrift in R way. This project is a R clone of ThriftPy.
library(thriftr)
The examples directory contains several different examples.
A simple example is found at the end of this document
The GitHub page for ThriftR can be found at:
https://github.com/systemincloud/thriftr
ThriftR make it super easy to write server/client code with thrift. Let's checkout this simple pingpong service demo.
We need a 'pingpong.thrift' file:
service PingPong {
string ping(),
}
Then we can make a server:
library(thriftr)
pingpong_thrift = thriftr::t_load("pingpong.thrift", module_name="pingpong_thrift")
Dispatcher <- R6::R6Class("Dispatcher",
public = list(
ping = function() {
return('pong')
}
)
)
server = thriftr::make_server(pingpong_thrift$PingPong, Dispatcher$new(), '127.0.0.1', 6000)
server$serve()
And a client:
library(thriftr)
pingpong_thrift = thriftr::t_load("pingpong.thrift", module_name="pingpong_thrift")
client = thriftr::make_client(pingpong_thrift$PingPong, "127.0.0.1", 6000)
cut(client$ping())