Question

I need to use erlang cassandra client(https://github.com/iamaleksey/seestar) in my ejabberd server for message logging purpose.But I can run seestar client separately.But if I include seestar files into ejabberd src folder, I ran into function_clause error.This error tells no gen_server's call function found.Please suggest some solution?

 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)
Was it helpful?

Solution

You're not supposed to call the functions in seestar_session_tests directly, but through the Eunit library. Try this instead:

eunit:test(seestar_session_tests, [verbose]).

(The exact cause of the error above is that seestar_session_tests:test_schema_queries expects a pid, which the test framework would give it, but you invoke it with a floating point number.)

The Eunit tests can also be invoked from the commond line through Rebar. Change to the seestar directory and run rebar eunit.

OTHER TIPS

You can use erlcass which is based on Datastax Official Cpp driver. To integrate just add it as dep to your rebar config file:

{erlcass, ".*", {git, "https://github.com/silviucpp/erlcass.git", {tag, "v2.2"}}}

Then into your application start method initialize the driver or use into you app.config the following:

{
    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">>}
            ]
        }
    ]
}.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top