Properties:
Name | Type | Description |
---|---|---|
name |
string | Name of the pool. Used only for logging. |
create |
PromisePool.Factory.create | Should create the item to be acquired, and return either a promise or the new client. |
destroy |
PromisePool.Factory.destroy | Should gently close any resources that the item is using. Called to destroy resources. |
validate |
PromisePool.Factory.validate | Optional. Should return true if the resource is still valid and false if it should be removed from the pool. Called before a resource is acquired from the pool. |
onRelease |
PromisePool.Factory.onRelease | Optional. May return a promise to indicate when a client is ready to be added back to the pool after being released. |
max |
number | Optional. Maximum number of items that can exist at the same time. Any further acquire requests
will be pushed to the waiting list. Defaults to |
min |
number | Optional. Minimum number of items in pool (including in-use). When the pool is created, or a
resource destroyed, this minimum will be checked. If the pool resource count is below the
minimum a new resource will be created and added to the pool. Defaults to |
idleTimeoutMillis |
number | Optional. Maximum period for resources to be idle (e.g. not acquired) before they are destroyed.
Defaults to |
reapIntervalMillis |
number | Optional. How frequently the pool will check for idle resources that need to be destroyed.
Defaults to |
drainCheckIntervalMillis |
number | Optional. How frequently the pool will check the status of waiting clients and unreturned
resources before destroying all the resources. Defaults to |
log |
bool | PromisePool.Factory.log | Optional. Whether the pool should log activity. If a function is provided, it will be called to
log messages. If |
priorityRange |
number | Optional. The range from 1 to be treated as a valid priority. Default is |
refreshIdle |
bool | Optional. Indicates if idle resources should be destroyed when left idle for |
returnToHead |
bool | Optional. Returns released object to the head of the available objects list. Default is false. |
- Source:
Type Definitions
create() → {Promise.<PromisePool.Client>}
- Source:
Returns:
A promise for a new client.
- Type
- Promise.<PromisePool.Client>
destroy(client) → (nullable) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
client |
PromisePool.Client | A resource that had been created earlier. |
- Source:
Returns:
If destruction is asynchronous, a promise should be returned that will resolve after the client is destroyed.
- Type
- Promise
log(msg, level)
Parameters:
Name | Type | Description |
---|---|---|
msg |
string | The message to be logged. |
level |
string | The importance of this log message. Possible values are: |
- Source:
onRelease(client) → (nullable) {Promise.<*>}
Parameters:
Name | Type | Description |
---|---|---|
client |
PromisePool.Client | A resource that has been released back to the pool. |
- Source:
Returns:
May return a promise, in which case the client wont join the pool until the promise resolves. If it is rejected, then the client will be destroyed instead.
- Type
- Promise.<*>
validate(client) → {bool}
Parameters:
Name | Type | Description |
---|---|---|
client |
PromisePool.Client | A resource that had been created earlier. |
- Source:
Returns:
True if the resource is still valid, otherwise false should be returned.
- Type
- bool