wpool
Worker pool main interface.
Worker pool main interface. Use functions provided by this module to manage your pools of workers
Types
custom_strategy() = fun(([atom()]) -> Atom :: atom())
name() = atom()
option() =
{overrun_warning, infinity | integer() >= 1} |
{overrun_handler, {Module :: atom(), Fun :: atom()}} |
{workers, integer() >= 1} |
{worker_opt, gen:options()} |
{worker, {Module :: atom(), InitArg :: term()}} |
{strategy, supervisor:strategy()} |
{worker_type, gen_fsm | gen_server} |
{pool_sup_intensity, integer() >= 0} |
{pool_sup_period, integer() >= 0}
stats() =
[{pool, name()} |
{supervisor, pid()} |
{options, [option()]} |
{size, integer() >= 0} |
{next_worker, integer() >= 1} |
{total_message_queue_len, integer() >= 0} |
{workers, [{integer() >= 1, worker_stats()}]}]
strategy() =
best_worker |
random_worker |
next_worker |
available_worker |
next_available_worker |
{hash_worker, term()} |
custom_strategy()
worker_stats() =
[{messsage_queue_len, integer() >= 0} |
{memory, integer() >= 1}]
Functions
start() -> ok | {error, {already_started, wpool}}
Starts the application
stop() -> ok
Stops the application
start_pool(Name::name()) -> {ok, pid()}
Equivalent to start_pool(Name, []).
start_pool(Name::name(), Options::[option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}
Starts (and links) a pool of N wpool_processes. The result pid belongs to a supervisor (in case you want to add it to a supervisor tree)
start_sup_pool(Name::name()) -> {ok, pid()}
Equivalent to start_sup_pool(Name, []).
start_sup_pool(Name::name(), Options::[option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}
Starts a pool of N wpool_processes supervised by wpool_sup
stop_pool(Name::name()) -> ok
Stops the pool
default_strategy() -> strategy()
Default strategy
call(Sup::name(), Call::term()) -> term()
Equivalent to call(Sup, Call, default_strategy()).
call(Sup::name(), Call::term(), Strategy::strategy()) -> term()
Equivalent to call(Sup, Call, Strategy, 5000).
call(Sup::name(), Call::term(), Fun::strategy(), Timeout::timeout()) -> term()
Picks a server and issues the call to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered
cast(Sup::name(), Cast::term()) -> ok
Equivalent to cast(Sup, Cast, default_strategy()).
cast(Sup::name(), Cast::term(), Fun::strategy()) -> ok
Picks a server and issues the cast to it
sync_send_event(Sup::name(), Event::term()) -> term()
Equivalent to sync_send_event(Sup, Event, default_strategy()).
sync_send_event(Sup::name(), Event::term(), Strategy::strategy()) -> term()
Equivalent to sync_send_event(Sup, Event, Strategy, 5000).
sync_send_event(Sup::name(), Event::term(), Fun::strategy(), Timeout::timeout()) -> term()
Picks a fsm and issues the event to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered
send_event(Sup::name(), Event::term()) -> ok
Equivalent to send_event(Sup, Event, default_strategy()).
send_event(Sup::name(), Event::term(), Fun::strategy()) -> ok
Picks a server and issues the event to it
send_all_state_event(Sup::name(), Event::term()) -> ok
Equivalent to send_all_state_event(Sup, Event, default_strategy()).
send_all_state_event(Sup::name(), Event::term(), Fun::strategy()) -> ok
Picks a server and issues the event to it
sync_send_all_state_event(Sup::name(), Event::term()) -> term()
Equivalent to sync_send_all_state_event(Sup, Event, default_strategy()).
sync_send_all_state_event(Sup::name(), Event::term(), Strategy::strategy()) -> term()
Equivalent to sync_send_all_state_event(Sup, Event, Strategy, 5000).
sync_send_all_state_event(Sup::name(), Event::term(), Fun::strategy(), Timeout::timeout()) -> term()
Picks a fsm and issues the event to it. For all strategies except available_worker, Timeout applies only to the time spent on the actual call to the worker, because time spent finding the worker in other strategies is negligible. For available_worker the time used choosing a worker is also considered
stats() -> [stats()]
Retrieves a snapshot of the pool stats
stats(Sup::name()) -> stats()
Retrieves a snapshot of a given pool stats