manifest / riak-connection-pool

Riak connection pool

Repository from Github https://github.commanifest/riak-connection-poolRepository from Github https://github.commanifest/riak-connection-pool

Riak connection pool

Build Status

How To Use

Build and run the docker container with Riak KV within it.

$ ./run-docker.sh

To build and start playing with the library, execute following commands in the shell:

$ make app shell

Here is a minimal example:

%% Creating a pool and adding it to the supervision tree.
Pool =
  #{name => default,
    size => 5,
    connection =>
      #{host => "192.168.99.100",
        port => 8087,
        options => [queue_if_disconnected]}},
ChildSpec = riakc_pool:child_spec(Pool),
supervisor:start_child(whereis(riakc_pool_sup), ChildSpec).

%% Getting a connection and locking it to the current process.
%% If process dies, connection will be released.
Pid = riakc_pool:lock(default),
%% Putting an object and getting it back.
riakc_pb_socket:put(Pid, riakc_obj:new(<<"groceries">>, <<"mine">>, <<"eggs & bacon">>)),
riakc_pb_socket:get(Pid, <<"groceries">>, <<"mine">>),
%% Releasing the connection.
riakc_pool:unlock(default, Pid).

To learn more about Riak client library refer to its documentation.

License

The source code is provided under the terms of the MIT license.

About

Riak connection pool

License:MIT License


Languages

Language:Erlang 87.8%Language:Shell 6.6%Language:Makefile 5.6%