View Source wpool (worker_pool v6.1.0)
Link to this section Summary
Functions
Casts a message to all the workers within the given pool.
Equivalent to call(Sup, Call, default_strategy()).
Equivalent to call(Sup, Call, Strategy, 5000).
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
Equivalent to cast(Sup, Cast, default_strategy()).
Picks a server and issues the cast to it
Default strategy
Retrieves the list of worker registered names. This can be useful to manually inspect the workers or do custom work on them.
Picks a server and issues the call to it. Timeout applies only for the time used choosing a worker in the available_worker strategy
Starts the application
Equivalent to start_pool(Name, []).
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)
Equivalent to start_sup_pool(Name, []).
Starts a pool of N wpool_processes supervised by
wpool_supRetrieves a snapshot of the pool stats
Retrieves a snapshot of a given pool stats
Stops the application
Stops the pool
Stops the pool
Link to this section Types
-type custom_strategy() :: fun(([atom()]) -> Atom :: atom()).
-type debug_flag() :: trace | log | statistics | debug | {logfile, string()}.
-type gen_option() :: {timeout, timeout()} | {debug, [debug_flag()]} | {spawn_opt, [proc_lib:spawn_option()]}.
-type gen_options() :: [gen_option()].
-type name() :: atom().
-type option() :: {overrun_warning, infinity | pos_integer()} | {max_overrun_warnings, infinity | pos_integer()} | {overrun_handler, {Module :: atom(), Fun :: atom()}} | {workers, pos_integer()} | {worker_opt, gen_options()} | {worker, {Module :: atom(), InitArg :: term()}} | {strategy, supervisor_strategy()} | {worker_type, gen_server} | {pool_sup_intensity, non_neg_integer()} | {pool_sup_shutdown, brutal_kill | timeout()} | {pool_sup_period, non_neg_integer()} | {queue_type, wpool_queue_manager:queue_type()} | {enable_callbacks, boolean()} | {callbacks, [module()]}.
-type stats() :: [{pool, name()} | {supervisor, pid()} | {options, [option()]} | {size, non_neg_integer()} | {next_worker, pos_integer()} | {total_message_queue_len, non_neg_integer()} | {workers, [{pos_integer(), worker_stats()}]}].
-type strategy() :: best_worker | random_worker | next_worker | available_worker | next_available_worker | {hash_worker, term()} | custom_strategy().
-type supervisor_strategy() :: {supervisor:strategy(), non_neg_integer(), pos_integer()}.
-type worker_stats() :: [{messsage_queue_len, non_neg_integer()} | {memory, pos_integer()}].
Link to this section Functions
-spec broadcast(wpool:name(), term()) -> ok.
-spec call(name(), term()) -> term().
Equivalent to call(Sup, Call, default_strategy()).
Equivalent to call(Sup, Call, Strategy, 5000).
-spec cast(name(), term()) -> ok.
Equivalent to cast(Sup, Cast, default_strategy()).
-spec default_strategy() -> strategy().
-spec get_workers(name()) -> [atom()].
-spec send_request(name(), term()) -> noproc | timeout | gen_server:request_id().
Equivalent to send_request(Sup, Call, default_strategy(), 5000).
Equivalent to send_request(Sup, Call, Strategy, 5000).
-spec start() -> ok | {error, {already_started, wpool}}.
-spec start_pool(name()) -> {ok, pid()}.
Equivalent to start_pool(Name, []).
-spec start_sup_pool(name()) -> {ok, pid()} | {error, {already_started, pid()} | term()}.
Equivalent to start_sup_pool(Name, []).
-spec start_sup_pool(name(), [option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}.
wpool_sup
-spec stats() -> [stats()].
-spec stop() -> ok.
-spec stop_pool(name()) -> true.
-spec stop_sup_pool(name()) -> ok.