pool_spec
This commit is contained in:
parent
deeaa491ca
commit
f7946cc711
|
@ -26,7 +26,7 @@
|
|||
|
||||
-module(ecpool).
|
||||
|
||||
-export([start_pool/3, start_sup_pool/3, stop_sup_pool/1,
|
||||
-export([pool_spec/4, start_pool/3, start_sup_pool/3, stop_sup_pool/1,
|
||||
with_client/2, with_client/3, name/1, workers/1]).
|
||||
|
||||
-type pool_type() :: random | hash | round_robin.
|
||||
|
@ -36,6 +36,10 @@
|
|||
| {auto_reconnect, false | pos_integer()}
|
||||
| tuple().
|
||||
|
||||
pool_spec(ChildId, Pool, Mod, Opts) ->
|
||||
{ChildId, {?MODULE, start_pool, [Pool, Mod, Opts]},
|
||||
permanent, 5000, supervisor, [ecpool_pool_sup]}.
|
||||
|
||||
%% @doc Start the pool
|
||||
-spec start_pool(atom(), atom(), [option()]) -> {ok, pid()} | {error, any()}.
|
||||
start_pool(Pool, Mod, Opts) when is_atom(Pool) ->
|
||||
|
|
|
@ -36,7 +36,7 @@ start_link(Pool, Mod, Opts) when is_atom(Pool) ->
|
|||
init([Pool, Mod, Opts]) ->
|
||||
WorkerSpec = fun(Id) ->
|
||||
{{worker, Id}, {ecpool_worker, start_link, [Pool, Id, Mod, Opts]},
|
||||
transient, 5000, worker, [ecpool_worker]}
|
||||
transient, 5000, worker, [ecpool_worker, Mod]}
|
||||
end,
|
||||
Workers = [WorkerSpec(I) || I <- lists:seq(1, pool_size(Opts))],
|
||||
{ok, { {one_for_one, 10, 60}, Workers} }.
|
||||
|
|
Loading…
Reference in New Issue