View Source wpool_pool (worker_pool v6.2.0)
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 wpool:pool_sup_intensity()
and wpool:pool_sup_intensity()
options respectively.
Link to this section Summary
Functions
Adds a callback module. The module must implement the
wpool_process_callbacks
behaviour.Picks the worker with the smaller queue of messages.
Calls all workers in the pool in parallel
Casts a message to all the workers within the given pool.
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.
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
Use this function to get the Worker pool record in a custom worker.
Retrieves the list of worker registered names. This can be useful to manually inspect the workers or do custom work on them.
Picks a worker base on a hash result.
phash2(Term, Range)
returns hash = integer, 0 <= hash < Range so1
must be addedSet next within the worker pool record. Useful when using a custom strategy function.
Picks the first available worker, if any
Picks the next worker in a round robin fashion
Picks a random worker
Removes a callback module.
Picks the first available worker and sends the request to it. The timeout provided considers only the time it takes to get a worker
Starts a supervisor with several
wpool_process
es as its childrenRetrieves the pool stats for all pools
Retrieves a snapshot of the pool stats
Get values from the worker pool record. Useful when using a custom strategy function.
Link to this section Types
-opaque wpool()
Link to this section Functions
-spec add_callback_module(wpool:name(), module()) -> ok | {error, term()}.
wpool_process_callbacks
behaviour.
-spec best_worker(wpool:name()) -> atom().
-spec broadcall(wpool:name(), term(), 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.
-spec broadcast(wpool:name(), term()) -> ok.
-spec call_available_worker(wpool:name(), any(), timeout()) -> atom().
-spec cast_to_available_worker(wpool:name(), term()) -> ok.
-spec find_wpool(atom()) -> undefined | wpool().
-spec get_workers(wpool:name()) -> [atom()].
-spec hash_worker(wpool:name(), term()) -> atom().
phash2(Term, Range)
returns hash = integer, 0 <= hash < Range so1
must be added
-spec next_available_worker(wpool:name()) -> atom().
-spec next_worker(wpool:name()) -> atom().
-spec random_worker(wpool:name()) -> atom().
-spec remove_callback_module(wpool:name(), module()) -> ok | {error, term()}.
-spec send_request_available_worker(wpool:name(), any(), timeout()) -> noproc | timeout | gen_server:request_id().
-spec start_link(wpool:name(), [wpool:option()]) -> {ok, pid()} | {error, {already_started, pid()} | term()}.
wpool_process
es as its children
-spec stats() -> [wpool:stats()].
-spec stats(wpool:name()) -> wpool:stats().
-spec worker_name(wpool:name(), pos_integer()) -> atom().