- Notifications
You must be signed in to change notification settings - Fork22
A simple non intrusive resource pool for connections
License
NotificationsYou must be signed in to change notification settings
erlware/episcina
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Episcina is designed as a pool for resources. Generally thoseresources are expected to be connections to some type of externalthing like a sql system. However, there is nothing sql specific aboutepiscina. You may generally consider it a small very focused poolimplementation that does not try to take ownership of your work.
Episcina will create any pools defined in the episcina's 'pools'environment parameter, which is a proplist that tells episcina how toconnect. There are several parameters that are required.
size
- The maximum size of the pooltimeout
- The maximum number of milliseconds that the a caller isallowed to hold a connection. See below for the consequences ofholding a connection open too long.connect_provider
- This is the function + arguments that will beused to provide connections. It contains the name of the module, thename of the function and the arguments to pass to thatfunction. There is an example below.close_provider
- This is tthe function + arguments that will beused to close connections. It contains the name of the module, thename of the function and any arguments needed to be passed to thatfunction. There is an example below.
Episcina also has two optional parameters:
max_restarts
: the number of restarts that are allowedto occur withinmax_seconds_between_restarts
seconds. (Default: 1000)max_seconds_between_restarts
: If more thanmax_restarts
restartsoccur withinmax_seconds_between_restarts
seconds, the episcina supervisorwill terminate all its child processes, then itself. (Default: 3600)
{episcina, [{max_restarts,2000}, {max_seconds_between_restarts,7200}, {pools, [{db1, [{size,10}, {timeout,10000}, {connect_provider, {pgsql,connect, ["localhost",5432,"my supersecret pass","postgresql", [{database,"foobar"}]]}}, {close_provider, {pgsql,close, []}}]}]}]}.
{ok,C}=episcina:get_connection(Pool,Timeout).
Pool
- Name of pool.Timeout
- Time, in milliseconds, to wait for a free connection.
ok=episcina:return_connection(Pool,Connection).
- Episcina monitors the process which called
get_connection
and returns theallocated connection to the pool if that process dies. - If a connection dies, a new one is created and added to the pool inits place.
- If the caller holds the pool longer the specified pool timeout thenan exit message is sent to the calling process and the connection isreturned to the pool.
About
A simple non intrusive resource pool for connections
Resources
License
Stars
Watchers
Forks
Packages0
No packages published