如何在Erlang中加载thrift客户端
我希望使用scribe从Erlang应用程序导出一些数据,但运行Thrift客户端时遇到问题。我在erlang lib目录中安装Thrift。我用的是:节俭-0.6.1 我找到了一些示例代码,可以通过thrift从erlang连接到scribe:如何在Erlang中加载thrift客户端,erlang,thrift,scribe,Erlang,Thrift,Scribe,我希望使用scribe从Erlang应用程序导出一些数据,但运行Thrift客户端时遇到问题。我在erlang lib目录中安装Thrift。我用的是:节俭-0.6.1 我找到了一些示例代码,可以通过thrift从erlang连接到scribe: {ok, C} = thrift_client:start_link("localhost", 1463, scribe_thrift, [{strict_read, fals
{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\u link
我想现在你需要像节俭客户端\u util:new(主机、端口、ProtoModule、选项)
在你的情况下,这将是:
thrift_client_util:new("localhost", 1463, scribe_thrift,
[{strict_read, false},
{strict_write, false},
{framed, true}]).
erlang中thrift API需要记住的一点是,所有调用都会返回一个新的客户机状态值,您必须在后续调用中使用该值。两次使用客户端状态值都会导致哭诉和咬牙切齿。几个月前,我将节俭与我的项目整合在一起。获取客户端需要一些初始化步骤 {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), {好的,TFactory}= 节俭插座运输:新运输工厂( “localhost”,8899,[]), {好的,工厂}= 节约二进制协议:新协议工厂(TFactory,[]), {ok,Protocol}=PFactory(), {ok,Client}=thrift_Client:new(协议,scribe_thrift),
要了解更多上下文,您可能可以查看my git repo中的a。从这个答案的观察结果可以看出,返回的客户端状态与原始状态相同。Archelus使用thrift_client_util:new的回复就是这个答案的包装器。