* riak-erlang-http-client
** Overview
riak-erlang-http-client is an Erlang client for Riak, using the HTTP interface
** Quick Start
You must have [[http://erlang.org/download.html][Erlang/OTP 20]] or later and a GNU-style build
system to compile and run =riak-erlang-http-client=.
#+BEGIN_SRC shell
git clone git://github.com/basho/riak-erlang-http-client.git
cd riak-erlang-http-client
make
#+END_SRC
If the Protocol Buffers Riak Erlang Client
([[http://github.com/basho/riak-erlang-client][riak-erlang-client]]) is already familiar to you, you should find
this client familiar. Just substitute calls to =riakc_pb_socket=
with calls to =rhc=.
As a quick example, here is how to create and retrieve a value with
the key "foo" in the bucket "bar" using the
riak-erlang-http-client.
First, start up an Erlang shell with the path to
=riak-erlang-http-client= and all dependenciess included, then
start =sasl= and =ibrowse=:
#+BEGIN_SRC shell
erl -pa path/to/riak-erlang-http-client/ebin path/to/riak-erlang-http-client/deps/*/ebin
Eshell V5.8.2 (abort with ^G)
1> [ ok = application:start(A) || A <- [sasl, ibrowse] ].
#+END_SRC
Next, create your client:
#+BEGIN_SRC erlang
2> IP = "127.0.0.1",
2> Port = 8098,
2> Prefix = "riak",
2> Options = [],
2> C = rhc:create(IP, Port, Prefix, Options).
{rhc,"10.0.0.42",80,"riak",[{client_id,"ACoc4A=="}]}
#+END_SRC
Sidenote: if you will be using the defaults, as in the example
above, you may call =rhc:create/0= instead of specifying the
defaults yourself.
Create a new object, and store it with =rhc:put/2=:
#+BEGIN_SRC erlang
3> Bucket = <<"bar">>,
3> Key = <<"foo">>,
3> Data = <<"hello world">>,
3> ContentType = <<"text/plain">>,
3> Object0 = riakc_obj:new(Bucket, Key, Data, ContentType),
3> rhc:put(C, Object0).
ok
#+END_SRC
Retrieve an object with =rhc:get/3=:
#+BEGIN_SRC erlang
4> Bucket = <<"bar">>,
4> Key = <<"foo">>,
4> {ok, Object1} = rhc:get(C, Bucket, Key).
{ok,{riakc_obj,<<"bar">>,<<"foo">>,
<<107,206,97,96,96,96,204,96,202,5,82,44,12,167,92,95,100,
48,37,50,230,177,50,...>>,
[{{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
<<"hello world">>}],
undefined,undefined}}
#+END_SRC
Please refer to the generated documentation for more information:
#+BEGIN_SRC shell
make doc && open doc/index.html
#+END_SRC
** Contributing
We encourage contributions to =riak-erlang-http-client= from the
community.
1) Fork the =riak-erlang-http-client= repository on
[[https://github.com/basho/riak-erlang-http-client][Github]].
2) Clone your fork or add the remote if you already have a clone of
the repository.
#+BEGIN_SRC shell
git clone git@github.com:yourusername/riak-erlang-http-client.git
# or
git remote add mine git@github.com:yourusername/riak-erlang-http-client.git
#+END_SRC
3) Create a topic branch for your change.
#+BEGIN_SRC shell
git checkout -b some-topic-branch
#+END_SRC
4) Make your change and commit. Use a clear and descriptive commit
message, spanning multiple lines if detailed explanation is
needed.
5) Push to your fork of the repository and then send a pull-request
through Github.
#+BEGIN_SRC shell
git push mine some-topic-branch
#+END_SRC
6) A Basho engineer or community maintainer will review your patch
and merge it into the main repository or send you feedback.
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Erlang
94.1%
Makefile
5.9%
* riak-erlang-http-client
** Overview
riak-erlang-http-client is an Erlang client for Riak, using the HTTP interface
** Quick Start
You must have [[http://erlang.org/download.html][Erlang/OTP 20]] or later and a GNU-style build
system to compile and run =riak-erlang-http-client=.
#+BEGIN_SRC shell
git clone git://github.com/basho/riak-erlang-http-client.git
cd riak-erlang-http-client
make
#+END_SRC
If the Protocol Buffers Riak Erlang Client
([[http://github.com/basho/riak-erlang-client][riak-erlang-client]]) is already familiar to you, you should find
this client familiar. Just substitute calls to =riakc_pb_socket=
with calls to =rhc=.
As a quick example, here is how to create and retrieve a value with
the key "foo" in the bucket "bar" using the
riak-erlang-http-client.
First, start up an Erlang shell with the path to
=riak-erlang-http-client= and all dependenciess included, then
start =sasl= and =ibrowse=:
#+BEGIN_SRC shell
erl -pa path/to/riak-erlang-http-client/ebin path/to/riak-erlang-http-client/deps/*/ebin
Eshell V5.8.2 (abort with ^G)
1> [ ok = application:start(A) || A <- [sasl, ibrowse] ].
#+END_SRC
Next, create your client:
#+BEGIN_SRC erlang
2> IP = "127.0.0.1",
2> Port = 8098,
2> Prefix = "riak",
2> Options = [],
2> C = rhc:create(IP, Port, Prefix, Options).
{rhc,"10.0.0.42",80,"riak",[{client_id,"ACoc4A=="}]}
#+END_SRC
Sidenote: if you will be using the defaults, as in the example
above, you may call =rhc:create/0= instead of specifying the
defaults yourself.
Create a new object, and store it with =rhc:put/2=:
#+BEGIN_SRC erlang
3> Bucket = <<"bar">>,
3> Key = <<"foo">>,
3> Data = <<"hello world">>,
3> ContentType = <<"text/plain">>,
3> Object0 = riakc_obj:new(Bucket, Key, Data, ContentType),
3> rhc:put(C, Object0).
ok
#+END_SRC
Retrieve an object with =rhc:get/3=:
#+BEGIN_SRC erlang
4> Bucket = <<"bar">>,
4> Key = <<"foo">>,
4> {ok, Object1} = rhc:get(C, Bucket, Key).
{ok,{riakc_obj,<<"bar">>,<<"foo">>,
<<107,206,97,96,96,96,204,96,202,5,82,44,12,167,92,95,100,
48,37,50,230,177,50,...>>,
[{{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
<<"hello world">>}],
undefined,undefined}}
#+END_SRC
Please refer to the generated documentation for more information:
#+BEGIN_SRC shell
make doc && open doc/index.html
#+END_SRC
** Contributing
We encourage contributions to =riak-erlang-http-client= from the
community.
1) Fork the =riak-erlang-http-client= repository on
[[https://github.com/basho/riak-erlang-http-client][Github]].
2) Clone your fork or add the remote if you already have a clone of
the repository.
#+BEGIN_SRC shell
git clone git@github.com:yourusername/riak-erlang-http-client.git
# or
git remote add mine git@github.com:yourusername/riak-erlang-http-client.git
#+END_SRC
3) Create a topic branch for your change.
#+BEGIN_SRC shell
git checkout -b some-topic-branch
#+END_SRC
4) Make your change and commit. Use a clear and descriptive commit
message, spanning multiple lines if detailed explanation is
needed.
5) Push to your fork of the repository and then send a pull-request
through Github.
#+BEGIN_SRC shell
git push mine some-topic-branch
#+END_SRC
6) A Basho engineer or community maintainer will review your patch
and merge it into the main repository or send you feedback.
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Erlang
94.1%
Makefile
5.9%