Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Failed to load latest commit information.
etc Documentation. Examples.
include Documentation. Examples.
src Documentation. Examples.
.gitignore .gitignore was added
COPYRIGHT Documentation. Examples.
LICENSE Documentation. Examples.
NOTICE notice added
rebar.config fix deps for standalone compilation UNISON-3336 Unison web dosent work after node fail

Riak database connection pool.

Main features

  • Graceful handling of riak nodes starts and shutdowns
  • simultaneous work with different riak clusters
  • parse_transform generation for interfaces from the client code
  • simple configuring using erlang configuration files
  • reconfiguration in runtime
  • tested in production at Unison Technologies

Getting started


You can build this software with rebar tool:

rebar get-deps && rebar compile

Usage as rebar dependency:

{riak_pool, ".*", {git, "", "master"}}

Important note: by default, all dependencies are fetched from repositories. You can change this setup in rebar.config file. But if you do so (e.g. in order to switch to the newest version of riakc), something might not work properly.


  • You can configure riak_pool with a configuration file of your release.

See configuration format description and example here

  • You also can reconfigure riak_pool in runtime with:



riak_pool has two different external interfaces.

Both of them are generated with parse_transformation from original riak_pb_socket client code.

parse_transformed modules act as a proxy to the client module, so you can use original riakc documentation for API description. It makes it possible to use the newest riak API without riak_pool code modification.

  • riak_pool interface is designed to work with connection explicitly:
take(Worker, Bucket, Key) ->
    {ok, Obj} = riak_pool:get(Worker, Bucket, Key),
    ok = riak_pool:delete_obj(Worker, Obj),

riak_pool:with_worker(fun ?MODULE:take/3, [<<"bucket">>, <<"key">>]).
riak_pool:with_worker(?MODULE, take, [<<"bucket">>, <<"key">>]).
riak_pool:with_worker(fun(Worker) -> take(Worker, <<"bucket">>, <<"key">>) end).
  • riak_pool_auto interface doesn't require connection management from the user.

It may look like a more convenient way but in some cases it's less efficient. Each call requires check-in and check-out pool operation. If you're dealing with a lot of operations, it's better to use riak_pool interface.

riak_pool_auto:get(<<"bucket">>, <<"key">>).
Something went wrong with that request. Please try again.