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

Enable stale member culling by default

New default behavior is to check for stale members once per minute
where max_age (stale member criteria) is 30 seconds.
Seth Falcon 12 лет назад
Родитель
Сommit
17f5590497
4 измененных файлов с 16 добавлено и 14 удалено
  1. 3 4
      README.org
  2. 8 7
      src/pooler.erl
  3. 2 2
      src/pooler.hrl
  4. 3 1
      test/pooler_tests.erl

+ 3 - 4
README.org

@@ -153,10 +153,9 @@ During a check, pool members that have not been used in more than
 =max_age= minutes will be removed until the pool size reaches
 =init_count=.
 
-The default value for =cull_interval= is ={0, min}= which disables
-stale member checking entirely. The =max_age= parameter has the same
-default value which will cause any members beyond =init_count= to be
-removed if scheduled culling is enabled.
+The default value for =cull_interval= is ={1, min}=. You can disable
+culling by specifying a value os ={0, min}=. The =max_age= parameter
+defaults to ={30, sec}=.
 
 *** Pool Configuration via =pooler:new_pool=
 You can create pools using =pooler:new_pool/1= when accepts a

+ 8 - 7
src/pooler.erl

@@ -93,12 +93,12 @@ manual_start() ->
 %% {@link take_group_member/1} and {@link return_group_member/2}.</dd>
 %% <dt>`cull_interval'</dt>
 %% <dd>Time between checks for stale pool members. Specified as
-%% `{Time, Unit}' where `Time' is a non-negative integer and `Unit'
-%% is one of `min', `sec', `ms', or `mu'. The default value of `{0,
-%% min}' disables stale member checking. When `Time' is greater than
-%% zero, a message will be sent to the pool at the configured interval
-%% to trigger the removal of members that have not been accessed in
-%% `max_age' time units.</dd>
+%% `{Time, Unit}' where `Time' is a non-negative integer and `Unit' is
+%% one of `min', `sec', `ms', or `mu'. The default value of `{1, min}'
+%% triggers a once per minute check to remove members that have not
+%% been accessed in `max_age' time units. Culling can be disabled by
+%% specifying a zero time vaule (e.g. `{0, min}'. Culling will also be
+%% disabled if `init_count' is the same as `max_count'.</dd>
 %% <dt>`max_age'</dt>
 %% <dd>Members idle longer than `max_age' time units are removed from
 %% the pool when stale checking is enabled via
@@ -106,7 +106,8 @@ manual_start() ->
 %% below `init_count'. The value is specified as `{Time, Unit}'. Note
 %% that timers are not set on individual pool members and may remain
 %% in the pool beyond the configured `max_age' value since members are
-%% only removed on the interval configured via `cull_interval'.</dd>
+%% only removed on the interval configured via `cull_interval'. The
+%% default value is `{30, sec}'.</dd>
 %% <dt>`member_start_timeout'</dt>
 %% <dd>Time limit for member starts. Specified as `{Time,
 %% Unit}'. Defaults to `{1, min}'.</dd>

+ 2 - 2
src/pooler.hrl

@@ -1,6 +1,6 @@
 -define(DEFAULT_ADD_RETRY, 1).
--define(DEFAULT_CULL_INTERVAL, {0, min}).
--define(DEFAULT_MAX_AGE, {0, min}).
+-define(DEFAULT_CULL_INTERVAL, {1, min}).
+-define(DEFAULT_MAX_AGE, {30, sec}).
 -define(DEFAULT_MEMBER_START_TIMEOUT, {1, min}).
 -define(POOLER_GROUP_TABLE, pooler_group_table).
 

+ 3 - 1
test/pooler_tests.erl

@@ -116,6 +116,7 @@ pooler_basics_via_config_test_() ->
              Pools = [[{name, test_pool_1},
                        {max_count, 3},
                        {init_count, 2},
+                       {cull_interval, {0, min}},
                        {start_mfa,
                         {pooled_gs, start_link, [{"type-0"}]}}]],
              application:set_env(pooler, pools, Pools),
@@ -465,7 +466,8 @@ pooler_scheduled_cull_test_() ->
                        {max_count, 10},
                        {init_count, 2},
                        {start_mfa, {pooled_gs, start_link, [{"type-0"}]}},
-                       {cull_interval, {200, ms}}]],
+                       {cull_interval, {200, ms}},
+                       {max_age, {0, min}}]],
              application:set_env(pooler, pools, Pools),
              %% error_logger:delete_report_handler(error_logger_tty_h),
              application:start(pooler)