Skip to content

Commit

Permalink
Update types and Readme that referred to old pool name
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Hannan committed May 21, 2011
1 parent 8ad7b12 commit 5cbf4de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -75,20 +75,20 @@ This driver does not provide helper functions for commands. Use `mongo:command`

### Pooling

A single (replset-)connection is thread-safe, i.e. multiple `mongo:do` actions can access it simultaneously. However, if you want to increase concurrency by using multiple connection simultaneously, you can create a pool of connections using the generic `pool` module with the appropriate factory object supplied by `mongo` module.
A single (replset-)connection is thread-safe, i.e. multiple `mongo:do` actions can access it simultaneously. However, if you want to increase concurrency by using multiple connection simultaneously, you can create a pool of connections using the generic `resource_pool` module with the appropriate factory object supplied by `mongo` module.

To create a connection pool of max size 10 to a single Host

> Pool = pool:new (mongo:connect_factory (Host), 10).
> Pool = resource_pool:new (mongo:connect_factory (Host), 10).

To create a rs-connection pool of max size 10 to a Replset

> Pool = pool:new (mongo:rs_connect_factory (Replset), 10).
> Pool = resource_pool:new (mongo:rs_connect_factory (Replset), 10).

To get a (replset-)connection from the pool

> {ok, Conn} = pool:get (Pool).
> {ok, Conn} = resource_pool:get (Pool).

`Conn` can then be supplied to `mongo:do`. `pool:get` will return `{error, Reason}` if can't connect.
`Conn` can then be supplied to `mongo:do`. `resource_pool:get` will return `{error, Reason}` if can't connect.

Close the pool when done using it and all its connection that were handed out via `pool:close`. It will close all its connections, as well as itself.
Close the pool when done using it and all its connection that were handed out via `resource_pool:close`. It will close all its connections, as well as itself.
2 changes: 1 addition & 1 deletion ebin/mongodb.app
@@ -1,6 +1,6 @@
{application, mongodb,
[{description, "Client interface to MongoDB, also known as the driver. See www.mongodb.org"},
{vsn, "0.0"},
{vsn, "0.2.1"},
{modules, [mongodb_app, mongo, mongo_protocol, mongo_connect, mongo_query, mongo_cursor, mvar, mongodb_tests, mongo_replset, resource_pool]},
{registered, []},
{applications, [kernel, stdlib]},
Expand Down
8 changes: 4 additions & 4 deletions src/mongo.erl
Expand Up @@ -47,8 +47,8 @@ connect (Host) -> mongo_connect:connect (Host).
%@doc Close connection to server
disconnect (Conn) -> mongo_connect:close (Conn).

-spec connect_factory (host()) -> pool:factory(connection()).
%@doc Factory for use with a connection pool. See pool module.
-spec connect_factory (host()) -> resource_pool:factory(connection()).
%@doc Factory for use with a connection pool. See resource_pool module.
connect_factory (Host) -> {Host, fun connect/1, fun disconnect/1, fun mongo_connect:is_closed/1}.

% Replica Set %
Expand All @@ -64,8 +64,8 @@ rs_connect (Replset) -> mongo_replset:connect (Replset).
%@doc Close cache of replset connections
rs_disconnect (ReplsetConn) -> mongo_replset:close (ReplsetConn).

-spec rs_connect_factory (replset()) -> pool:factory(rs_connection()).
%@doc Factory for use with a rs_connection pool. See pool module.
-spec rs_connect_factory (replset()) -> resource_pool:factory(rs_connection()).
%@doc Factory for use with a rs_connection pool. See resource_pool module.
rs_connect_factory (Replset) -> {Replset, fun (RS) -> RC = rs_connect (RS), {ok, RC} end, fun rs_disconnect/1, fun mongo_replset:is_closed/1}.

% Action %
Expand Down

0 comments on commit 5cbf4de

Please sign in to comment.