项目作者: manifest

项目描述 :
Riak connection pool
高级语言: Erlang
项目地址: git://github.com/manifest/riak-connection-pool.git
创建时间: 2016-09-12T18:31:30Z
项目社区:https://github.com/manifest/riak-connection-pool

开源协议:MIT License

下载


Riak connection pool

Build Status

How To Use

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

  1. $ ./run-docker.sh

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

  1. $ make app shell

Here is a minimal example:

  1. %% Creating a pool and adding it to the supervision tree.
  2. Pool =
  3. #{name => default,
  4. size => 5,
  5. connection =>
  6. #{host => "192.168.99.100",
  7. port => 8087,
  8. options => [queue_if_disconnected]}},
  9. ChildSpec = riakc_pool:child_spec(Pool),
  10. supervisor:start_child(whereis(riakc_pool_sup), ChildSpec).
  11. %% Getting a connection and locking it to the current process.
  12. %% If process dies, connection will be released.
  13. Pid = riakc_pool:lock(default),
  14. %% Putting an object and getting it back.
  15. riakc_pb_socket:put(Pid, riakc_obj:new(<<"groceries">>, <<"mine">>, <<"eggs & bacon">>)),
  16. riakc_pb_socket:get(Pid, <<"groceries">>, <<"mine">>),
  17. %% Releasing the connection.
  18. 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.