4

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.

2 Answers 2

6

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.

1
  • the observation from the answer of this post shows that the returned client state is the same as the original one.
    – gextra
    Jul 21, 2013 at 13:03
2

I got thrift integrated with my project a couple of months back. There are some initialization steps required to obtain the client.


  {ok, TFactory} = 
    thrift_socket_transport:new_transport_factory(
      "localhost", 8899, []),
  {ok, PFactory} = 
    thrift_binary_protocol:new_protocol_factory(TFactory, []),
  {ok, Protocol} = PFactory(),
  {ok, Client} = thrift_client:new(Protocol, scribe_thrift),

For more context, you can probably take a look at a module from my git repo.

1
  • The reply from archaelus using thrift_client_util:new is a wrapper for this answer.
    – gextra
    Nov 1, 2013 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.