Copyright © 2011-2013 Seth Falcon
Behaviours: gen_server.
Authors: Seth Falcon (seth@userprimary.net).
This is the main interface to the pooler application
To integrate with your application, you probably want to call application:start(pooler) after having specified appropriate configuration for the pooler application (either via a config file or appropriate calls to the application module to set the application's config).| accept_member/2 | For INTERNAL use. |
| call_free_members/2 | Invokes Fun with arity 1 over all free members in pool with PoolName. |
| call_free_members/3 | Invokes Fun with arity 1 over all free members in pool with PoolName. |
| code_change/3 | |
| handle_call/3 | |
| handle_cast/2 | |
| handle_info/2 | |
| init/1 | |
| manual_start/0 | |
| new_pool/1 | Start a new pool described by the proplist PoolConfig. |
| pool_child_spec/1 | Get child spec described by the proplist PoolConfig. |
| pool_stats/1 | Obtain runtime state info for all pools. |
| pool_utilization/1 | Obtain utilization info for a pool. |
| return_group_member/2 | Return a member that was taken from the group
GroupName. |
| return_group_member/3 | Return a member that was taken from the group GroupName. |
| return_member/2 | Return a member to the pool so it can be reused. |
| return_member/3 | Return a member to the pool so it can be reused. |
| rm_group/1 | Terminates the group and all pools in that group. |
| rm_pool/1 | Terminate the named pool. |
| start/0 | |
| start_link/1 | |
| stop/0 | |
| take_group_member/1 | Take a member from a randomly selected member of the group
GroupName. |
| take_member/1 | Obtain exclusive access to a member from PoolName. |
| take_member/2 | Obtain exclusive access to a member of 'PoolName'. |
| terminate/2 |
accept_member(PoolName::atom() | pid(), MemberPid::pid() | {noproc, term()}) -> ok
For INTERNAL use. Adds MemberPid to the pool.
call_free_members(PoolName::atom() | pid(), Fun::fun((pid()) -> term())) -> Res
Res = [{ok, term()} | {error, term()}]
Invokes Fun with arity 1 over all free members in pool with PoolName.
call_free_members(PoolName::atom() | pid(), Fun, Timeout::timeout()) -> Res
Fun = fun((pid()) -> term())Res = [{ok, term()} | {error, term()}]
Invokes Fun with arity 1 over all free members in pool with PoolName.
Timeout sets the timeout of gen_server call.
code_change(OldVsn::term(), State::term(), Extra::term()) -> {ok, term()}
handle_call(Request, From, Pool) -> any()
handle_cast(Msg::term(), Pool::term()) -> {noreply, term()}
handle_info(Info::term(), Pool::term()) -> {noreply, term()}
init(Pool::#pool{}) -> {ok, #pool{}, 0}
manual_start() -> any()
new_pool(PoolConfig) -> any()
Start a new pool described by the proplist PoolConfig. The
following keys are required in the proplist:
nameinit_countinit_count members will be started in parallel.max_countstart_mfa{Mod, Fun, Args} describing how to start
new pool members.In addition, you can specify any of the following optional configuration options:
groupgroup value can be accessed using
take_group_member/1 and return_group_member/2.cull_interval{Time, Unit} where Time is a non-negative integer and Unit is
one of min, sec, ms, or mu. The default value of {1, min}
triggers a once per minute check to remove members that have not
been accessed in max_age time units. Culling can be disabled by
specifying a zero time vaule (e.g. {0, min}. Culling will also be
disabled if init_count is the same as max_count.max_agemax_age time units are removed from
the pool when stale checking is enabled via
cull_interval. Culling of idle members will never reduce the pool
below init_count. The value is specified as {Time, Unit}. Note
that timers are not set on individual pool members and may remain
in the pool beyond the configured max_age value since members are
only removed on the interval configured via cull_interval. The
default value is {30, sec}.member_start_timeout{Time,
Unit}. Defaults to {1, min}.pool_child_spec(PoolConfig::[{atom(), term()}]) -> supervisor:child_spec()
Get child spec described by the proplist PoolConfig.
pooler:new_pool/1 for info about PoolConfig.
pool_stats(PoolName::atom() | pid()) -> [tuple()]
Obtain runtime state info for all pools.
Format of the return value is subject to change.pool_utilization(PoolName::atom() | pid()) -> [{atom(), integer()}]
Obtain utilization info for a pool.
Format of the return value is subject to change, but for now it will be a proplist to maintain backcompat with R16.return_group_member(GroupName::atom(), MemberPid::pid() | error_no_members) -> ok
Return a member that was taken from the group
GroupName. This is a convenience function for
return_group_member/3 with Status of ok.
return_group_member(GroupName::atom(), MemberPid::pid() | error_no_members, Status::ok | fail) -> ok
Return a member that was taken from the group GroupName. If
Status is ok the member is returned to the pool from which is
came. If Status is fail the member will be terminated and a new
member added to the appropriate pool.
return_member(PoolName::atom() | pid(), Pid::pid() | error_no_members) -> ok
Return a member to the pool so it can be reused.
return_member(PoolName::atom() | pid(), Pid::pid() | error_no_members, Status::ok | fail) -> ok
Return a member to the pool so it can be reused.
IfStatus is 'ok', the member is returned to the pool. If
Status is 'fail', the member is destroyed and a new member is
added to the pool in its place.
rm_group(GroupName::atom()) -> ok | {error, {failed_rm_pools, [atom()]}}
Terminates the group and all pools in that group.
If termination of any member pool fails, rm_group/1 returns
{error, {failed_delete_pools, Pools}}, where Pools is a list
of pools that failed to terminate.
rm_pool(PoolName) -> any()
Terminate the named pool.
start() -> ok
start_link(Pool) -> any()
stop() -> ok
take_group_member(GroupName::atom()) -> pid() | error_no_members | {error_no_group, atom()}
Take a member from a randomly selected member of the group
GroupName. Returns MemberPid or error_no_members. If no
members are available in the randomly chosen pool, all other pools
in the group are tried in order.
take_member(PoolName::atom() | pid()) -> pid() | error_no_members
Obtain exclusive access to a member from PoolName.
take_member(PoolName::atom() | pid(), Timeout::non_neg_integer() | time_spec()) -> pid() | error_no_members
Obtain exclusive access to a member of 'PoolName'.
If no members are available, wait for up to Timeout milliseconds for a member to become available. Waiting requests are served in FIFO order. If no member is available within the specified timeout, error_no_members is returned.Timeout can be either milliseconds as integer or {duration, time_unit}
terminate(Reason::term(), State::term()) -> ok
Generated by EDoc