dfrankow
dfrankow

Reputation: 21387

Does R have thrift bindings?

Apache Thrift is a way to declare data types and interfaces. You can compile the thrift into many other languages, called "bindings." Is there a compiler than can produce an R binding for thrift? I don't see one.

Upvotes: 4

Views: 298

Answers (1)

Marek Jagielski
Marek Jagielski

Reputation: 822

Still in its early adoption phase, but you can try: thriftr

service PingPong {
    string ping(),
}

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()

Client:

library(thriftr)

pingpong_thrift = thriftpy::t_load("pingpong.thrift", 
module_name="pingpong_thrift")

client = thriftpy::make_client(pingpong_thrift$PingPong, "127.0.0.1", 6000)
cut(client$ping())

Upvotes: 3

Related Questions