riakc_pb_socket:start_link()使用rebar3和Erlang时出错

时间:2016-12-28 01:00:14

标签: erlang riak rebar3

我使用牛仔休息http处理程序创建了一个erlang应用程序。该应用程序将数据存储在riak kv中。但是我无法连接到我的riak节点以返回其余api的数据。

当我调用riakc_pb_socket:start_link(" 127.0.0.1",8087)时,我收到错误。

以下是我对riak进行调用的代码段。

get_json(Req, State) ->
    {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),
    Body = riakc_pb_socket:is_connected(Pid),
    {Body, Req, State}.

以下是发生错误时的堆栈跟踪。

  =ERROR REPORT==== 28-Dec-2016::00:15:52 ===
  Error in process <0.359.0> on node 'paddylenderapi@PaddyLender-2' with 
  exit value:
  {[{reason,undef},
  {mfa,{paddylenderapi_rest_handler,get_json,2}},
  {stacktrace,
  [{riakc_pb_socket,start_link,["127.0.0.1",8087],[]},
   {paddylenderapi_rest_handler,get_json,2,
       [{file,
            "/home/oladipo/Projects/Erlang/PaddyLender/paddylenderapi
  /_build/prod/lib/paddylenderapi/src/paddylenderapi_rest_handler.erl"},
        {line,37}]},
   {cowboy_rest,call,3,
       [{file,
            "/home/oladipo/Projects/Erlang/PaddyLender/paddylenderapi
  /_build/default/lib/cowboy/src/cowboy_rest.erl"},
        {line,972}]},
   {cowboy_rest,set_resp_body,2,
       [{file,
            "/home/oladipo/Projects/Erlang/PaddyLender/paddylenderapi
  /_build/default/lib/cowboy/src/cowboy_rest.erl"},
        {line,854}]},
   {cowboy_protocol,execute,4,
       [{file,
            "/home/oladipo/Projects/Erlang/PaddyLender/paddylenderapi
  /_build/default/lib/cowboy/src/cowboy_protocol.erl"},
        {line,442}]}]},

请参阅下面的我的rebar.config内容:

    {erl_opts, [debug_info]}.
      {deps, [
         {cowboy, {git, "git://github.com/ninenines/cowboy.git", {tag, "1.0.1"}}},
        {riakc, "2.5.*", {git, "https://github.com/basho/riak-erlang-client", {tag, "2.5.1"}}},
        {riak_pb, {git, "https://github.com/basho/riak_pb", {tag, "2.1.4.2"}}}
    ]
     }.

     {plugins, [
        rebar3_run
    ]
}.


{relx, [
        {release, {paddylenderapi, "0.0.1"},[paddylenderapi]},
        {dev_mode, true},
        {include_erts, false},
        {extended_start_script, true}
    ]
}.

{overrides,
 [
  {override, rebar3_protobuffs_plugin, [{deps, [ {protobuffs, {git, "https://github.com/basho/erlang_protobuffs.git", {tag, "0.9.0"}}}]}]},

  {override, riak_pb, [
                        {plugins, [{riak_pb_msgcodegen,
                                   {git, "https://github.com/tsloughter/riak_pb_msgcodegen.git",
                                    {ref, "dc51330"}}},
                                  {rebar3_protobuffs_plugin,
                                   {git, "https://github.com/cmkarlsson/rebar3_protobuffs_plugin",
                                    {tag, "0.1.1"}}}]},
                       {provider_hooks, [{pre, [{compile, {protobuffs, compile}},
                                                {compile, riak_pb_msgcodegen}]}]}]}
  ]
}.

1 个答案:

答案 0 :(得分:-1)

我建议你在paddylenderapi.app.src中的'applications'部分没有riak_kv。这就是为什么这个应用程序不会放在发布lib文件夹中的原因。所以你得到了undef错误。