Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

shorten factory names

  • Loading branch information...
commit c6a491334e68248d214a614c100ac0326c4845a1 1 parent aec087c
Tony Hannan authored
Showing with 8 additions and 17 deletions.
  1. +2 −2 README.md
  2. +6 −15 src/mongo.erl
View
4 README.md
@@ -79,11 +79,11 @@ A single (replset-)connection is thread-safe, i.e. multiple `mongo:do` actions c
To create a connection pool of max size 10 to a single Host
- > Pool = pool:new (mongo:connection_factory (Host), 10).
+ > Pool = 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_connection_factory (Replset), 10).
+ > Pool = pool:new (mongo:rs_connect_factory (Replset), 10).
To get a (replset-)connection from the pool
View
21 src/mongo.erl
@@ -4,10 +4,9 @@
-export_type ([maybe/1]).
-export_type ([host/0, connection/0]).
--export ([connect/1, disconnect/1, connection_factory/1]).
-
+-export ([connect/1, disconnect/1, connect_factory/1]).
-export_type ([replset/0, rs_connection/0]).
--export ([rs_connect/1, rs_primary/1, rs_secondary_ok/1, rs_disconnect/1, rs_connection_factory/1]).
+-export ([rs_connect/1, rs_disconnect/1, rs_connect_factory/1]).
-export_type ([action/1, db/0, write_mode/0, read_mode/0, failure/0]).
-export ([do/5]).
@@ -48,9 +47,9 @@ connect (Host) -> mongo_connect:connect (Host).
% Close connection to server
disconnect (Conn) -> mongo_connect:close (Conn).
--spec connection_factory (host()) -> pool:factory(connection()).
+-spec connect_factory (host()) -> pool:factory(connection()).
% Factory for use with a connection pool. See pool module.
-connection_factory (Host) -> {Host, fun connect/1, fun disconnect/1, fun mongo_connect:is_closed/1}.
+connect_factory (Host) -> {Host, fun connect/1, fun disconnect/1, fun mongo_connect:is_closed/1}.
% Replica Set %
@@ -61,21 +60,13 @@ connection_factory (Host) -> {Host, fun connect/1, fun disconnect/1, fun mongo_c
% Create new cache of connections to replica set members starting with seed members. No connection attempted until rs_primary or rs_secondary_ok called.
rs_connect (Replset) -> mongo_replset:connect (Replset).
--spec rs_primary (rs_connection()) -> {ok, connection()} | {error, reason()}. % IO
-% Return connection to current primary in replica set
-rs_primary (ReplsetConn) -> mongo_replset:primary (ReplsetConn).
-
--spec rs_secondary_ok (rs_connection()) -> {ok, connection()} | {error, reason()}. % IO
-% Return connection to a current secondary in replica set or primary if none
-rs_secondary_ok (ReplsetConn) -> mongo_replset:secondary_ok (ReplsetConn).
-
-spec rs_disconnect (rs_connection()) -> ok. % IO
% Close cache of replset connections
rs_disconnect (ReplsetConn) -> mongo_replset:close (ReplsetConn).
--spec rs_connection_factory (replset()) -> pool:factory(rs_connection()).
+-spec rs_connect_factory (replset()) -> pool:factory(rs_connection()).
% Factory for use with a rs_connection pool. See pool module.
-rs_connection_factory (Replset) -> {Replset, fun (RS) -> RC = rs_connect (RS), {ok, RC} end, fun rs_disconnect/1, fun mongo_replset:is_closed/1}.
+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 %
Please sign in to comment.
Something went wrong with that request. Please try again.