worker_pool.
Behaviours: supervisor.
Top supervisor for a worker_pool.
This supervisor supervises wpool_process_sup (which is the worker's supervisor) together with
auxiliary servers that help keep the whole pool running and in order.
one_for_all but the intensity and period may be
changed from their defaults by the t:wpool:pool_sup_intensity() and
t:wpool:pool_sup_intensity() options respectively.
abstract datatype: wpool()
| add_callback_module/2 | Adds a callback module. |
| best_worker/1 | Picks the worker with the smaller queue of messages. |
| broadcall/3 | Calls all workers in the pool in parallel. |
| broadcast/2 | Casts a message to all the workers within the given pool. |
| call_available_worker/3 | Picks the first available worker and sends the call to it. |
| cast_to_available_worker/2 | Casts a message to the first available worker. |
| find_wpool/1 | Use this function to get the Worker pool record in a custom worker. |
| get_workers/1 | Retrieves the list of worker registered names. |
| hash_worker/2 | Picks a worker base on a hash result. |
| next/2 | Set next within the worker pool record. |
| next_available_worker/1 | Picks the first available worker, if any. |
| next_worker/1 | Picks the next worker in a round robin fashion. |
| random_worker/1 | Picks a random worker. |
| remove_callback_module/2 | Removes a callback module. |
| run_with_available_worker/3 | Picks the first available worker and sends the call to it. |
| send_request_available_worker/3 | Picks the first available worker and sends the request to it. |
| start_link/2 | Starts a supervisor with several wpool_processes as its children. |
| stats/0 | Retrieves the pool stats for all pools. |
| stats/1 | Retrieves a snapshot of the pool stats. |
| worker_name/2 | |
| wpool_get/2 | Get values from the worker pool record. |
add_callback_module(Pool::wpool:name(), Module::module()) -> ok | {error, term()}
Adds a callback module.
The module must implement the wpool_process_callbacks behaviour.
best_worker(Name::wpool:name()) -> atom()
throws no_workers
Picks the worker with the smaller queue of messages.
broadcall(Name::wpool:name(), Call::term(), Timeout::timeout()) -> {[Replies::term()], [Errors::term()]}
Calls all workers in the pool in parallel
Waits for responses in parallel too, and it assumes that if any response times out, all of them did too and therefore exits with reason timeout like a regulargen_server does.
broadcast(Name::wpool:name(), Cast::term()) -> ok
Casts a message to all the workers within the given pool.
call_available_worker(Name::wpool:name(), Call::any(), Timeout::timeout()) -> any()
throws no_workers | timeout
Picks the first available worker and sends the call to it. The timeout provided includes the time it takes to get a worker and for it to process the call.
cast_to_available_worker(Name::wpool:name(), Cast::term()) -> ok
Casts a message to the first available worker. Since we can wait forever for a wpool:cast to be delivered but we don't want the caller to be blocked, this function just forwards the cast when it gets the worker
find_wpool(Name::atom()) -> undefined | wpool()
Use this function to get the Worker pool record in a custom worker.
get_workers(Name::wpool:name()) -> [atom()]
Retrieves the list of worker registered names. This can be useful to manually inspect the workers or do custom work on them.
hash_worker(Name::wpool:name(), HashKey::term()) -> atom()
throws no_workers
Picks a worker base on a hash result.
phash2(Term, Range)returns hash = integer, 0 <= hash < Range so
1must be added
Set next within the worker pool record. Useful when using a custom strategy function.
next_available_worker(Name::wpool:name()) -> atom()
throws no_workers | no_available_workers
Picks the first available worker, if any
next_worker(Name::wpool:name()) -> atom()
throws no_workers
Picks the next worker in a round robin fashion
random_worker(Name::wpool:name()) -> atom()
throws no_workers
Picks a random worker
remove_callback_module(Pool::wpool:name(), Module::module()) -> ok | {error, term()}
Removes a callback module.
run_with_available_worker(Name::wpool:name(), Run::wpool:run(Result), Timeout::timeout()) -> Result
throws no_workers | timeout
Picks the first available worker and sends the call to it. The timeout provided includes the time it takes to get a worker and for it to process the call.
send_request_available_worker(Name::wpool:name(), Call::any(), Timeout::timeout()) -> noproc | timeout | gen_server:request_id()
Picks the first available worker and sends the request to it. The timeout provided considers only the time it takes to get a worker
start_link(Name::wpool:name(), Options::wpool:options()) -> supervisor:startlink_ret()
Starts a supervisor with several wpool_processes as its children
stats() -> [wpool:stats()]
Retrieves the pool stats for all pools
stats(Name::wpool:name()) -> wpool:stats()
throws no_workers
Retrieves a snapshot of the pool stats
worker_name(Name::wpool:name(), I::pos_integer()) -> atom()
Get values from the worker pool record. Useful when using a custom strategy function.
Generated by EDoc