我需要在我的ejabberd服务器中使用erlang cassandra客户端(https://github.com/iamaleksey/seestar)进行消息记录。但我可以单独运行seestar客户端。但是如果我将seestar文件包含到ejabberd src文件夹中,我遇到了function_clause错误。这个错误告诉没有找到gen_server的调用函数。请建议一些解决方案吗?
The error when I debug the code is :
(ejabberd@localhost)1> seestar_session_tests:session_test_().
{foreach,#Fun<seestar_session_tests.0.112079720>,
#Fun<seestar_session_tests.1.112079720>,
[#Fun<seestar_session_tests.2.112079720>,
#Fun<seestar_session_tests.3.112079720>,
#Fun<seestar_session_tests.4.112079720>,
#Fun<seestar_session_tests.5.112079720>]}
(ejabberd@localhost)2> seestar_session_tests:test_schema_queries(0.112079720).
** exception exit: {{function_clause,[{gen,call,
[0.11207972,'$gen_call',
{request,7,
<<0,0,0,95,67,82,69,65,84,69,32,75,69,89,83,80,...>>,
true},
infinity],
[{file,"gen.erl"},{line,146}]},
{gen_server,call,3,[{file,"gen_server.erl"},{line,184}]},
{seestar_session,request,3,
[{file,"seestar_session.erl"},{line,209}]},
{seestar_session,perform,3,
[{file,"seestar_session.erl"},{line,156}]},
{seestar_session_tests,test_schema_queries,1,
[{file,"seestar_session_tests.erl"},{line,33}]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,576}]},
{shell,exprs,7,[{file,"shell.erl"},{line,668}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,623}]}]},
{gen_server,call,
[0.11207972,
{request,7,
<<0,0,0,95,67,82,69,65,84,69,32,75,69,89,83,80,65,67,69,
...>>,
true},
infinity]}}
in function gen_server:call/3 (gen_server.erl, line 188)
in call from seestar_session:request/3 (seestar_session.erl, line 209)
in call from seestar_session:perform/3 (seestar_session.erl, line 156)
in call from seestar_session_tests:test_schema_queries/1 (seestar_session_tests.erl, line 33)
答案 0 :(得分:1)
您不应该直接调用seestar_session_tests
中的函数,而是通过Eunit库调用。试试这个:
eunit:test(seestar_session_tests, [verbose]).
(上述错误的确切原因是seestar_session_tests:test_schema_queries
需要一个pid,测试框架会给它一个pid,但是你用浮点数调用它。)
Eunit测试也可以通过Rebar从commond线调用。切换到seestar
目录并运行rebar eunit
。
答案 1 :(得分:0)
您可以使用基于erlcass的Datastax Official Cpp driver。 要集成,只需将其作为dep添加到rebar配置文件中:
{erlcass, ".*", {git, "https://github.com/silviucpp/erlcass.git", {tag, "v2.2"}}}
然后进入你的应用程序start方法初始化驱动程序或使用app.config中的以下内容:
{ erlcass, [ { cluster_options, [ {contact_points, <<"127.0.0.1">>}, {port, 9042}, {number_threads_io, 4}, {queue_size_io, 128000}, {max_connections_host, 5}, {pending_requests_high_watermark, 128000}, {tcp_nodelay, true}, {tcp_keepalive, {true, 1800}}, {keyspace, <<"keyspace_kere">>} ] } ] }.