{"id":15714009,"url":"https://github.com/hashnuke/riak_pool","last_synced_at":"2025-05-12T23:20:34.711Z","repository":{"id":11017489,"uuid":"13345699","full_name":"HashNuke/riak_pool","owner":"HashNuke","description":"Provides pooled Riak connections for Elixir apps. Re-connects automatically upon disconnection.","archived":false,"fork":false,"pushed_at":"2013-12-18T16:34:16.000Z","size":210,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T04:32:48.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HashNuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-05T13:40:04.000Z","updated_at":"2022-08-22T19:24:48.000Z","dependencies_parsed_at":"2022-09-23T14:00:16.164Z","dependency_job_id":null,"html_url":"https://github.com/HashNuke/riak_pool","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Friak_pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Friak_pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Friak_pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashNuke%2Friak_pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashNuke","download_url":"https://codeload.github.com/HashNuke/riak_pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253837925,"owners_count":21972065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T21:34:31.199Z","updated_at":"2025-05-12T23:20:34.676Z","avatar_url":"https://github.com/HashNuke.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# riak_pool\n\nProvides pooled Riak connections for Elixir. Re-connects automatically upon disconnection.\n\nCan also be used in Erlang. Based on Basho's [Riak erlang client](https://github.com/basho/riak-erlang-client)\n\n## Install\n\n* To use this in your Elixir project, add it to your dependency list in `mix.exs`\n\n  ```elixir\n  defp deps do\n    [\n      {:riak_pool, github: \"HashNuke/riak_pool\"}\n    ]\n  end\n  ```\n\n* Run `mix deps.get`\n\n## Starting RiakPool\n\nThere are two ways to start RiakPool\n\n#### Manually\n\n* `RiakPool.start_link(address, port)`\n\n  ```elixir\n  RiakPool.start_link '127.0.0.1', 8087\n  ```\n\n* `RiakPool.start_link(address, port, options)`\n\n  ```elixir\n  RiakPool.start_link('127.0.0.1', 8087, [\n      pool_options: [size: 6, max_overflow: 12]\n    ])\n  ```\n\n\n__Valid options are__\n\n* `pool_options` - options for the pool. Default value for `size` is 5 and `max_overflow` is 10.\n* `connection_options` - options for the Riak connection\n* `retry_interval` - incase of disconnection from Riak, this is the number of seconds (interval), at which a re-connection will be tried for. By default the value is `60` (seconds).\n\n\n#### Add it to your supervision tree\n\nHere's an example. Notice the `init` function.\n\n```elixir\ndefmodule YourApp.Supervisor do\n  use Supervisor.Behaviour\n\n  def start_link do\n    :supervisor.start_link(__MODULE__, [])\n  end\n\n  def init([]) do\n    children = [\n      # We are connecting to localhost, on port 8087.\n      # You can also pass a third argument for size options\n      worker(RiakPool, ['127.0.0.1', 8087])\n    ]\n    supervise children, strategy: :one_for_one\n  end\nend\n```\n\n\n## Usage\n\nThe library provides the following functions.\n\n#### Testing Riak connection\n\n    RiakPool.ping\n\nUsed to test if connection to your database is fine. Should return `:pong`.\n\n    iex(1)\u003e RiakPool.ping\n    :pong\n\n\n#### Put objects\n\n    RiakPool.put(riakc_obj)\n\nUsed to create or update values in the database. Accepts a riak object, created with the `:riakc_obj` module as the argument. Refer to this [blog post](http://akash.im/2013/09/30/using-riak-with-elixir.html) on how to use the `:riakc_obj` module to encapsulate your data.\n\n\n#### Get objects\n\n    RiakPool.get(bucket, key)\n\nUsed to get the value stored for a key from in a bucket. It accepts a bucket name and the key.\n\n\n#### Delete\n\n    RiakPool.delete(bucket, key)\n\nUsed to delete a key/value from a bucket in the database. It accepts a bucket name and the key to delete.\n\n\n#### Running your own stuff\n\n    RiakPool.run(fun)\n\nPass a function that accepts a worker pid as the argument. It'll run the function for you.\n\nUse this function, to perform other tasks, that this library doesn't provide helper functions for.  You can then use the worker pid with the `:riakc_pb_socket` module to connect to Riak and do something on your own.\n\nHere's an example that lists keys in the \"students\" bucket:\n\n```elixir\nRiakPool.run fn(worker)-\u003e\n  :riakc_pb_socket.list_keys worker, \"students\"\nend\n```\n\n## Credits\n\n[Akash Manohar](http://github.com/HashNuke) wrote this.\n\nRiakPool is available in the public domain. Or optionally under the [MIT License](https://github.com/HashNuke/riak_pool/blob/master/LICENSE).\n\nIf you use it somewhere, send me an email to tell me about it - that'll make me extremely happy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashnuke%2Friak_pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashnuke%2Friak_pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashnuke%2Friak_pool/lists"}