如何在Erlang中加载thrift客户端

Mic*_*ski 3 erlang thrift scribe

我希望使用scribe从Erlang应用程序中导出一些数据,但我在运行Thrift客户端时遇到问题.我在erlang lib目录中安装Thrift.我正在使用:thrift-0.6.1

我找到了一些示例代码,用于从erlang通过thrift连接到scribe:

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

但是erlang返回了这个错误:

** exception error: undefined function thrift_client:start_link/4
Run Code Online (Sandbox Code Playgroud)

当我尝试运行时application:start(thrift),我看到一些代码完成thrift*

7> thrift_client:
   call/3         close/1        module_info/0  module_info/1  new/2          
   send_call/3   
Run Code Online (Sandbox Code Playgroud)

而且没有方法start_link.

arc*_*lus 5

我想现在你想要这样的东西 thrift_client_util:new(Host, Port, ProtoModule, Options)

在你的情况下将是:

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

要记住erlang中的thrift API,重要的一点是所有调用都会返回一个新的客户端状态值,您必须将该值用于后续调用.使用客户状态值两次会导致哭泣和咬牙切齿.