GithubHelp home page GithubHelp logo

willcode2surf / riak-erlang-http-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basho/riak-erlang-http-client

0.0 2.0 0.0 280 KB

Riak Erlang client using the HTTP interface

License: Other

riak-erlang-http-client's Introduction

riak-erlang-http-client

Overview

Travis-CI :: https://secure.travis-ci.org/basho/riak-erlang-http-client.png

riak-erlang-http-client is an Erlang client for Riak, using the HTTP interface

Quick Start

You must have Erlang/OTP R13B04 or later and a GNU-style build system to compile and run riak-erlang-http-client.

git clone git://github.com/basho/riak-erlang-http-client.git
cd riak-erlang-http-client
make

If the Protocol Buffers 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:

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] ].

Next, create your client:

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=="}]}

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:

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

Retrieve an object with rhc:get/3:

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}}

Please refer to the generated documentation for more information:

make doc && open doc/index.html

Contributing

We encourage contributions to riak-erlang-http-client from the community.

  1. Fork the riak-erlang-http-client repository on Github.
  2. Clone your fork or add the remote if you already have a clone of the repository.
git clone [email protected]:yourusername/riak-erlang-http-client.git
# or
git remote add mine [email protected]:yourusername/riak-erlang-http-client.git
  1. Create a topic branch for your change.
git checkout -b some-topic-branch
  1. Make your change and commit. Use a clear and descriptive commit message, spanning multiple lines if detailed explanation is needed.
  2. Push to your fork of the repository and then send a pull-request through Github.
git push mine some-topic-branch
  1. A Basho engineer or community maintainer will review your patch and merge it into the main repository or send you feedback.

riak-erlang-http-client's People

Contributors

beerriot avatar dne avatar evanmcc avatar marccampbell avatar metajack avatar russelldb avatar rustyio avatar rzezeski avatar seancribbs avatar slfritchie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.