Home

Awesome

OTP Process Pool

Recent changes

11/23/2011

8/14/2011

Quick Start

  1. Create a pooly.conf configuration file in the priv directory
  2. Configure one or more pools in the configuration file
  3. Create an app config file for your application which includes:
    [{pooly, [{config_file, LocationOfFile}]}].

    e.g. [{pooly, [{config_file, "priv/pooly.conf"}]}].
    This will allow pooly to use your application's priv directory as opposed to its own.
  1. Start up erlang using the -config directive passing it the name of your config file. For example, if your application config file is named, myApp.config, you would type: erl -config myApp
> application:start(pooly).
> {ok, Pid} = pooly:check_out(poolName).
> pooly:check_in(poolName, Pid).

Configuration

Global pool tuning parameters

All parameters are optional. If the parameter is absent, the default will be used.

Pool Worker Setup

Any of the above global tuning parameters can be overridden for a specific pool. The pool will only call start_link on the module specified.

See pooly.conf.sample for a sample configuration file.

API

Until I document the code, please refer here on how to use Pooly.

Check out a process from the pool:

pooly:check_out(PoolName)
-> {ok, Pid}
-> {error, pool_exhausted} - The pool has reached maximum capacity as determined by the max_pool_size

Check in a process from the pool:

pooly:check_in(PoolName, Pid) -> ok

Retrieve the number of available processes:

pooly:idle_count(PoolName) -> {ok, integer()}

Retrieve the number of busy processes:

pooly:busy_count(PoolName) -> {ok, integer()}

Returns the total number of workers the pool is managing (busy + available):

pooly:total_count(PoolName) -> {ok, integer()}

License & Copyright

Copyright ©2011 Andrew Berman

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.