new Pool(optsopt)
Class representing a connection pool
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
object |
<optional> |
Constructor options |
- Source:
Methods
acquire(copt) → {Promise.<Connection, Error>}
Acquire a connection from the pool
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
c |
Connection | string |
<optional> |
A connection object or a context ID string to indicate which connection to be aquired from the pool. If this is null, a randon connection will be aquired from the pool. |
- Source:
Returns:
- A promise to a connection object or
an Error if rejected.
- Type
- Promise.<Connection, Error>
close(context) → {Promise.<string, Error>}
Close a context and release the reserved connection back to the pool
Parameters:
Name | Type | Description |
---|---|---|
context |
string | Context ID |
- Source:
Returns:
- A promise to a context ID string which
resolves after the context is closed or an Error if rejected.
- Type
- Promise.<string, Error>
options(opts)
Set options
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | Options |
- Source:
release(c)
Release a connection back to the pool
Parameters:
Name | Type | Description |
---|---|---|
c |
Connection | string | Connection object or a context ID |
- Source:
reserve(context) → {Connection}
Reserve a connection to be used with a new context
Parameters:
Name | Type | Description |
---|---|---|
context |
string | Context ID |
- Source:
Returns:
- A connection object reserved for this context.
- Type
- Connection