123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>pooler - An OTP Process Pool Application</title>
- <link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
- </head>
- <body bgcolor="white">
- <div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
- <h1>pooler - An OTP Process Pool Application</h1>
- <p>Copyright © 2011 Seth Falcon</p>
- <p><b>Authors:</b> Seth Falcon (<a href="mailto:seth@userprimary.net"><tt>seth@userprimary.net</tt></a>).</p>
- <p>
- The pooler application allows you to manage pools of OTP behaviors
- such as gen_servers, gen_fsms, or supervisors, and provide consumers
- with exclusive access to pool members using pooler:take_member.</p>
- <p>See the README.org file for a good introduction to what pooler is all
- about.</p>
- <h3><a name="Pooler_Configuration">Pooler Configuration</a></h3>
- <p>Pool configuration is specified in the pooler application's
- environment. This can be provided in a config file using <code>-config</code> or
- set at startup using <code>application:set_env(pooler, pools, Pools)</code>.
- Here's an example config file that creates three pools of
- Riak pb clients each talking to a different node in a local cluster:</p>
- <pre>% pooler.config
- % Start Erlang as: erl -config pooler
- % -*- mode: erlang -*-
- % pooler app config
- [
- {pooler, [
- {pools, [
- [{name, "rc8081"},
- {max_count, 5},
- {init_count, 2},
- {start_mfa,
- {riakc_pb_socket, start_link, ["localhost", 8081]}}],
- [{name, "rc8082"},
- {max_count, 5},
- {init_count, 2},
- {start_mfa,
- {riakc_pb_socket, start_link, ["localhost", 8082]}}],
- [{name, "rc8083"},
- {max_count, 5},
- {init_count, 2},
- {start_mfa,
- {riakc_pb_socket, start_link, ["localhost", 8083]}}]
- ]}
- ]}
- ].</pre>
- <h3><a name="Using_pooler">Using pooler</a></h3>
- <p>Here's an example session:</p>
- <pre>application:start(pooler).
- P = pooler:take_member(),
- % use P
- pooler:return_member(P, ok).</pre>
- <p>Once started, the main interaction you will have with pooler is through
- two functions, <code>take_member/0</code> and <code>return_member/2</code>.</p>
- Call <code>pooler:take_member()</code> to obtain a member from a randomly
- selected pool. When you are done with it, return it to the pool using
- <code>pooler:return_member(Pid, ok)</code>. If you encountered an error using
- the member, you can pass <code>fail</code> as the second argument. In this case,
- pooler will permanently remove that member from the pool and start a
- new member to replace it. If your process is short lived, you can
- omit the call to <code>return_member</code>. In this case, pooler will detect
- the normal exit of the consumer and reclaim the member.
- <hr>
- <div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
- <p><i>Generated by EDoc, Apr 17 2011, 16:02:59.</i></p>
- </body>
- </html>
|