我使用牛仔休息 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}]}]}]}
]
}.