此問題是之前詢問過的Including the Erlang client lib的延續。使用來自Riak的氮氣中的Erlang客戶端庫
我能夠通過改變包括圖書館:
到:
{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}}},
在rel/nitrogen/rebar.config
和lib
文件夾下用make重新編譯
現在,我已經與安裝,我不知道我應該在哪裏實施riakc_pb_socket
庫作爲suggested in the docs
我試圖把
{ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),
到nitrogen_sup:init()
但我收到此錯誤信息:
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
我應該做這方面的應用程序初始化過程中一次了Riak數據庫,或者經常作爲處理新的請求。我看了一些關於連接池的討論,這是否會在應用程序初始化期間設置一次,然後鏈接到新進程。
我是新來erlang/OTP和這個框架,所以任何方向將不勝感激。
補充說:
當我運行通過bin/nitrogen console
氮的應用程序,我能夠運行{ok, Pid} = riakc_pb_socket:start_link("127.0.0.1",8087).
我也設法從riakc_pb_socket:ping(Pid).
得到pong
回來,我想現在的問題是:在哪些文件通常設置/管理關於查詢/讀取/寫入的riak連接?
感謝您的回答。不過,我會花一點時間在接受之前消化/嘗試您的建議解決方案。 – neildaemond