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
.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With