Skip to content

Commit

Permalink
KAZOO-3257: add support for pool_size, pool_overflow, and pool_thresh…
Browse files Browse the repository at this point in the history
…old from config.ini
  • Loading branch information
k-anderson committed Jan 24, 2015
1 parent 6f50ab6 commit 237a57c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
3 changes: 0 additions & 3 deletions applications/ecallmgr/src/ecallmgr_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
-export([start_link/0]).
-export([init/1]).

-define(POOL_SIZE, 100).
-define(OVERFLOW_POOL_SIZE, 100).

-define(CHILDREN, [?WORKER('ecallmgr_init')
,?SUPER('ecallmgr_auxiliary_sup')
,?SUPER('ecallmgr_call_sup')
Expand Down
39 changes: 30 additions & 9 deletions core/whistle_amqp-1.0.0/src/wh_amqp_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,14 @@
-define(POOL_NAME, 'wh_amqp_pool').
-define(POOL_SIZE, 150).
-define(POOL_OVERFLOW, 100).

-define(POOL_ARGS, [[{'worker_module', 'wh_amqp_worker'}
,{'name', {'local', ?POOL_NAME}}
,{'size', ?POOL_SIZE}
,{'max_overflow', ?POOL_OVERFLOW}
,{'neg_resp_threshold', 1}
]]).
-define(POOL_THRESHOLD, 1).

-define(SERVER, ?MODULE).
-define(CHILDREN, [?WORKER('wh_amqp_connections')
,?SUPER('wh_amqp_connection_sup')
,?WORKER('wh_amqp_assignments')
,?WORKER('wh_amqp_history')
,?WORKER('wh_amqp_bootstrap')
,?WORKER_NAME_ARGS('poolboy', ?POOL_NAME, ?POOL_ARGS)
]).

%% ===================================================================
Expand Down Expand Up @@ -79,4 +72,32 @@ init([]) ->
MaxRestarts = 5,
MaxSecondsBetweenRestarts = 10,
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
{'ok', {SupFlags, ?CHILDREN}}.

PoolSize =
case wh_config:get(wh_config:get_node_section_name(), 'pool_size') of
[] -> ?POOL_SIZE;
[Size|_] -> wh_util:to_integer(Size)
end,

PoolOverflow =
case wh_config:get(wh_config:get_node_section_name(), 'pool_overflow') of
[] -> ?POOL_OVERFLOW;
[Overflow|_] -> wh_util:to_integer(Overflow)
end,

PoolThreshold =
case wh_config:get(wh_config:get_node_section_name(), 'pool_threshold') of
[] -> ?POOL_THRESHOLD;
[Threshold|_] -> wh_util:to_integer(Threshold)
end,

PoolArgs = [{'worker_module', 'wh_amqp_worker'}
,{'name', {'local', ?POOL_NAME}}
,{'size', PoolSize}
,{'max_overflow', PoolOverflow}
,{'neg_resp_threshold', PoolThreshold}
],

Children = ?CHILDREN ++ [?WORKER_NAME_ARGS('poolboy', ?POOL_NAME, [PoolArgs])],

{'ok', {SupFlags, Children}}.

0 comments on commit 237a57c

Please sign in to comment.