Skip to content

Commit

Permalink
Merge pull request #84 from opscode/of/blocking_take_pooler
Browse files Browse the repository at this point in the history
Leverage blocking take_member in pooler
  • Loading branch information
oferrigni committed Oct 27, 2014
2 parents a76c711 + 8883bfe commit 7e5f773
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions itest/itest.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
["Chris", "Maier", 0, <<"2011-10-03 16:47:46">>, true],
["Elvis", "Presley", 16, <<"2011-10-04 16:47:46">>, false]]).
-define(POOL_NAME, sqerl).
-define(POOLER_TIMEOUT, 500).
-define(MAX_POOL_COUNT, 3).

-compile([export_all]).
Expand All @@ -49,6 +50,7 @@ setup_env() ->
ok = application:set_env(sqerl, db_pass, "itest"),
ok = application:set_env(sqerl, db_name, ?GET_ARG(db, Info)),
ok = application:set_env(sqerl, idle_check, 10000),
ok = application:set_env(sqerl, pooler_timeout, ?POOLER_TIMEOUT),
%% we could also call it like this:
%% {prepared_statements, statements()},
%% {prepared_statements, "itest/statements_pgsql.conf"},
Expand Down Expand Up @@ -196,9 +198,9 @@ basic_test_() ->
]}.

kill_pool(1) ->
pooler:take_member(?POOL_NAME);
pooler:take_member(?POOL_NAME, ?POOLER_TIMEOUT);
kill_pool(X) ->
pooler:take_member(?POOL_NAME),
pooler:take_member(?POOL_NAME, ?POOLER_TIMEOUT),
kill_pool(X - 1).

pool_overflow() ->
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{git, "git://github.com/opscode/epgsql.git", "master"}},

{pooler, ".*",
{git, "git://github.com/seth/pooler.git", {tag, "1.2.2"}}},
{git, "git://github.com/seth/pooler.git", {tag, "1.3.3"}}},

{envy, ".*",
{git, "git://github.com/manderson26/envy.git", {branch, "master"}}}
Expand Down
2 changes: 1 addition & 1 deletion src/sqerl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
-define(PGSQL_ERROR_CODES, [{<<"23505">>, conflict}, {<<"23503">>, foreign_key}]).

checkout() ->
pooler:take_member(sqerl).
pooler:take_member(sqerl, envy:get(sqerl, pooler_timeout, 0, integer)).

checkin(Connection) ->
pooler:return_member(sqerl, Connection).
Expand Down

0 comments on commit 7e5f773

Please sign in to comment.