4

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

我找到了一些示例代码,可以通过 thrift 从 erlang 连接到抄写员:

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

但 erlang 正在返回此错误:

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

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

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

而且没有办法start_link

4

2 回答 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.

于 2011-04-29T23:24:55.540 回答
2

几个月前,我将节俭与我的项目整合在一起。获取客户端需要一些初始化步骤。

  {好的,TFactory} =
    thrift_socket_transport:new_transport_factory(
      "本地主机", 8899, []),
  {好的,PFactory} =
    thrift_binary_protocol:new_protocol_factory(TFactory, []),
  {ok, 协议} = PFactory(),
  {ok, Client} = thrift_client:new(Protocol, scribe_thrift),

有关更多上下文,您可能可以查看我的 git 存储库中的一个模块。

于 2011-04-30T04:40:26.520 回答