/poolmongo

A thin wrapper that fuses mongodb-erlang with poolboy (mostly for my own sake)

Primary LanguageErlangApache License 2.0Apache-2.0

poolmongo

A thin wrapper that fuses mongodb-erlang with poolboy (mostly for my own sake)

usage

  • Add poolmongo as a dependency to your erlang.mk project
DEPS = ... poolmongo ...
dep_poolmongo = git https://github.com/peffis/poolmongo master
  • Add a pool configuration to your sys.config (any config really, but keep the name "pmongo" as the name for the pool)
[
...
{poolmongo, [ 
               {pools, [
                        {pmongo, [
                                  {size, 10},
                                  {max_overflow, 20}
                                 ], [
                                     {host, "localhost"},
                                     {port, 27017},
                                     {database, <<"your mongodb database">>},
                                     {w_mode, safe},
                                     {r_mode, slave_ok}
                                    ]}
                       ]}
             ]}, 
...
].
  • If you make use of .app.src you need to add poolmongo to the list of applications
{application, your_app,
 [
  {description, ""},
  {vsn, "0.9"},
  {registered, []},
  {applications, [
                  ...
		  poolmongo,
		  ...
                 ]},
  {mod, { your_app, []}},
  {included_applications, []},
  {modules, []},
  {env, []}
 ]}.
  • Build your system
make
  • Use the API in the pmongo module which is the same API as mongodb-erlang's mc_worker_api except that the first argument, the Connection, is removed (as the connection is handled by poolboy)