This question is a continuation of Including the Erlang client lib which was asked before.
I was able to include the library by changing:
{mimetypes, ".*", {git, "git://github.com/spawngrid/mimetypes", {branch, master}}},
%% Uncomment the following lines and comment the bottom lines with specific
%% tags to always pull the latest versions
{nitrogen_core, ".*", {git, "git://github.com/nitrogen/nitrogen_core",{branch, master}}},
to:
{mimetypes, ".*", {git, "git://github.com/spawngrid/mimetypes", {branch, master}}},
{riakc, "1.4.1",
{git, "git://github.com/basho/riak-erlang-client",
{tag, "1.4.1"}}},
%% Uncomment the following lines and comment the bottom lines with specific
%% tags to always pull the latest versions
{nitrogen_core, ".*", {git, "git://github.com/nitrogen/nitrogen_core",{branch, master}}},
in rel/nitrogen/rebar.config
and recompiling with make
Now that I have those installed under the lib
folder, I'm not sure where I should be implementing the riakc_pb_socket
lib as suggested in the docs
I've tried putting
{ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),
into nitrogen_sup:init()
but i get this error message:
application: nitrogen
exited: {{{badmatch,{error,{tcp,econnrefused}}},
[{nitrogen_sup,init,1,
[{file,"/home/neil/proj/nitrogen/rel/nitrogen/site/src/nitrogen_sup.erl"},
{line,43}]},
{supervisor,init,1,[{file,"supervisor.erl"},{line,239}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,239}]}]},
{nitrogen_app,start,[normal,[]]}}
type: temporary
Am I supposed to make this connection to riak database once during the app initialization, or often as new requests are handled. I saw some talk of connection pools, would this be something that I setup once during app initialization, then link to with new processes.
I'm new to erlang/OTP and this framework, so any direction will be greatly appreciated.
added:
When I run the nitrogen app via bin/nitrogen console
, I am able to run {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1",8087).
and I do manage to get a pong
back from riakc_pb_socket:ping(Pid).
I guess the question now is: In which files does one generally setup/manage riak connections with respect to queries/reads/writes?