Including Riak Nitrogen Erlang Client Library

I am just starting out with a web application using nitrogen and everything is going well. But I also want my application to interact with the riak db that I created, and I have problems.

I am confused about how to “enable” the erlang client interface so that my code in nitrogen can access it.

(https://wiki.basho.com/display/RIAK/Erlang+Client+PBC)

I am new to erlang and nitrogen, but I mean, in general, for erlang, how to include other libraries as a reference? I just take the compiled ray files and throw it somewhere, and then include the -include line at the top of my erlang code? if so, where can I throw these files for nitrogen (it has its own separate instance of erlang node, which I think)

+3
source share
2 answers

If you run everything on one node, just call what you need. If a node is created with Erlang / OPT release processing rules, this means that all necessary libraries are loaded into the virtual machine.

-include is used only to include header files, for example. Records of definitions or macros.

All of this should be transparent to you, because the rebar (basho build) does a great job of this.

To use some lib, make sure that it is in the deps folder as a result of the correct reinforcement configuration (deps section). The next is to change systools.config to rel / files, which configures node (selects applications from deps / for inclusion in the running system).

And that’s all.

+3
source

:

  • Erlang Basho. Basho Erlang/OTP.

  • , . , "slim-release", Basho Erlang

  • riak-erlang-client github. .. /$MYPROJECT/lib, $MYPROJECT - . git clone git://github.com/basho/riak-erlang-client.git. riak-erlang-client lib

  • rebar.config, nano ../$MYPROJECT/rebar.config, riak-erlang-client. ** riakc dep **, make slim_cowboy

{deps, [

  {cowboy,       ". *"     , {git, "git://github.com/ninenines/cowboy", {tag, "1.0.0" }}},
%%         
 %%,     
{simple_bridge,       ". *"     , {git,  "git://github.com/nitrogen/simple_bridge", {branch, master}}},
{nprocreg,       ". *"     , {git,  "git://github.com/nitrogen/nprocreg", {branch, master}}},
{atomic_core,       ". *"     , {git,  "git://github.com/nitrogen/nitrogen_core", {branch, master}}},

%%  riak-erlang-client 
{riakc,  "1.4.1", {git, "git://github.com/basho/riak-erlang-client", {tag,  "1.4.1" }}},
%%  riak-erlang-client 

{sync,       ". *"     , {git,  "git://github.com/rustyio/sync", {branch, master}}}

%%    
% {simple_bridge,       ". *"     , {git,  "git://github.com/nitrogen/simple_bridge", {tag, "v2.0.0-beta5" }}},
% {nprocreg,       ". *"     , {git,  "git://github.com/nitrogen/nprocreg", {tag, "v0.2.1" }}},
% {atom_core,       ". *"     , {git,  "git://github.com/nitrogen/nitrogen_core", {tag, "v2.3.0-beta6" }}},
% {sync,       ". *"     , {git,  "git://github.com/rustyio/sync", {tag, "4dbe32bb4" }}}
 > 

]}.

  1. ../$MYPROJECT , make all.

  2. ./bin/nitrogen console. riak {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", <PORT>). .

0

Source: https://habr.com/ru/post/1775790/


All Articles