Search code examples
erlangthriftscribe

How to load thrift client in Erlang


I wish to use scribe to export some data from a Erlang application, but I have a problem with running Thrift client. I install Thrift, in the erlang lib directory. I'm using: thrift-0.6.1

I found some example code to connect from erlang via thrift to scribe:

{ok, C} = thrift_client:start_link("localhost", 1463, scribe_thrift, 
                                     [{strict_read, false}, 
                                      {strict_write, false}, 
                                      {framed, true}]),

but erlang is returning this error:

** exception error: undefined function thrift_client:start_link/4

When I try to run application:start(thrift), for a moment I see some code completion for thrift*

7> thrift_client:
   call/3         close/1        module_info/0  module_info/1  new/2          
   send_call/3   

and there is no method start_link.


Solution

  • I think these days you want something like thrift_client_util:new(Host, Port, ProtoModule, Options)

    which in your case would be:

    thrift_client_util:new("localhost", 1463, scribe_thrift,
                           [{strict_read, false}, 
                            {strict_write, false}, 
                            {framed, true}]).
    

    And an important point to bear in mind with the thrift API in erlang is that all calls return you a new client state value which you must use for subsequent calls. Using a client state value twice leads to wailing and the gnashing of teeth.