myndzi / pool2

38 stars 8 forks source link

Document constructor options ? #9

Closed asafyish closed 9 years ago

asafyish commented 9 years ago

Hi,

There are a few parameters that are not documented: acquireTimeout disposeTimeout pingTimeout idleTimeout syncInterval

Some them I was able to understand from the source, but some I wasn't. Is it possible to document them ?

myndzi commented 9 years ago

The docs could definitely be more thorough, right now they're just a stopgap since I was writing this module for use in another module. I do plan to provide more thorough documentation, but in the meantime:

Note that "acquire" and "dispose" in the constructor are for acquiring a resource INTO the pool FROM your supplied function and disposing of a resource FROM the pool using your supplied function; this is not the same as pool.{acquire|release|remove|destroy}, which are the functions used on the pool instance that a consumer uses to request resources from the pool and release them back.

The timers are as follows:

acquireTimeout: how long to wait before giving up when trying to acquire a resource for the pool (a timeout here will abort this attempt to acquire a resource, but the pool will keep trying so long as it is 'live')

disposeTimeout: how long to wait before giving up when trying to clean up a resource nicely (a timeout here will cause the resource to be destroyed)

pingTimeout: how long to wait before giving up for a response from the ping function (ping is used to test resources' validity before allocating them to a request; a timeout here will cause the resource to be disposed of)

idleTimeout: how long a resource must be idle before freeing it, used to prune the pool down to the minimum

syncInterval: how often to check idle resources for pruning and/or acquire new resources to bring the pool up to the minimum

asafyish commented 9 years ago

Thanks for the prompt reply !

myndzi commented 9 years ago

No problem!

myndzi commented 9 years ago

I've finally pushed some more detailed documentation to master now explaining all the options