Connect to Riak and store data via Erlang -
Connect to Riak and store data via Erlang -
my goal of test module start storing info input on own in local node.
i have set local node on computer. attached new erlang module via riak attach.
in module test.erl there riakconnect function far:
riakconnect() -> riakc_pb_socket:start_link("127.0.0.1", 8087).
i have receive part in same module looks similar (now commented out):
riakreceive() -> receive {store, bucket, key, value} -> ... end.
the problem when attach file, node's console says riakc_pb_socket:start_link() undefined , nil reacts in there.
i assume missing info here.
are running node riakc_pb_socket
in path? if repo's readme have start vm compiled erlang binary files added erl
path
$ erl -pa $path_to_riakc/ebin $path_to_riakc/deps/*/ebin
if in erlang shell can verify able load module l(modulename).
function. , check path (where binaries) code:get_path().
. modify (add new directories) general rule should have right vm starting script/command.
and finally, if developing own application (which think are) tools rebar. there describe dependencies, erlang-riak client, , help downloading , compiling them. strart vm simple
erl -pa ebin -pa deps/*/ebin
edit after comments
riak application, , erlang can connect wright it. within working production stuff. quite dangerous, or be. should leave riak be. @ to the lowest degree internals. riak gives stable interface connect form outside.
so lets that. live riaks nodes running, , write yet application "speak" it. , speaking utilize riak-erlang client basho itself.
first step creating development environment utilize of rebar build tool. fallowing getting started guide
$ mkdir myapp $ cd myapp $ wget https://raw.github.com/wiki/rebar/rebar/rebar && chmod u+x rebar $ rebar create-app appid=myapp
other few other files have src
folder can (and will) set custom modules. can check if compiles ./rebar compile
command. compiled files in bin
folder (same level src
) , have .beam
extension (just java have .java
).
next thing need accual library. need riakc_pb_socket.beam
run riakc_pb_socket
module. easiest way download sources , compile them. , quite easy since utilize rebar building stuff.
we gonna create rebar.config
file , populate dependency
{deps, [{ riakc, ".*" , {git, "https://github.com/basho/riak-erlang-client.git", {branch, "1."}}} ]}.
and download , compile
$ ./rebar get-deps compile
and should able start new erlang vm, give name, add together path bineries (from custom modules, , dependencies) , shell run code.
$ erl -sname myapp -pa ebin -pa deps/*/ebin (myapp@localhost) 1> custom_module:riakconnect().
and should pass.
if run code straight scheme console erl -run
or escript.
and should going.
erlang riak
Comments
Post a Comment