Просмотр исходного кода

Fix strategy fifo as default if not defined.

Added fifo as default instead of lifo if it's not declared in pool args.
This is so each connection will be used so we minimize connection timeout from mysql.
Raoul Hess 10 лет назад
Родитель
Сommit
dcb8df52e5
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      src/mysql_poolboy.erl

+ 6 - 1
src/mysql_poolboy.erl

@@ -30,7 +30,12 @@
 
 %% @doc Adds a pool to the started mysql_poolboy application.
 add_pool(PoolName, PoolArgs, MysqlArgs) ->
-    PoolSpec = child_spec(PoolName, PoolArgs, MysqlArgs),
+    %% We want strategy fifo as default instead of lifo.
+    PoolArgs1 = case proplists:is_defined(strategy, PoolArgs) of
+        true  -> PoolArgs;
+        false -> PoolArgs ++ [{strategy, fifo}]
+    end,
+    PoolSpec = child_spec(PoolName, PoolArgs1, MysqlArgs),
     supervisor:start_child(mysql_poolboy_sup, PoolSpec).
 
 %% @doc Returns a mysql connection to the given pool.