Constructor
new SessionPool(database, optionsopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
database |
Database |
The DB instance. |
|
options |
SessionPoolOptions |
<optional> |
Configuration options. |
Extends
- EventEmitter
Members
available
availableReads
availableWrites
borrowed
Total number of borrowed sessions.
currentWriteFraction
isFull
Flag to determine if Pool is full.
numPendingReads
numPendingWrites
numReadWaiters
numWriteWaiters
pendingPrepare
reads
size
Total number of sessions in the pool.
totalPending
Total number of sessions currently being created by the pool.
totalWaiters
Total number of waiters for a session from the pool.
writes
Methods
close(callback)
Closes the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
SessionPoolCloseCallback |
The callback function. |
Fires:
- SessionPool#event:close
getReadSession(callback)
Retrieve a read session.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
GetReadSessionCallback |
The callback function. |
getSession(callback)
Retrieve a session for read or read/write operations.
Session pooling has been replaced by multiplexed sessions, so this returns the database's shared multiplexed session, together with a new read/write transaction, instead of a pooled session.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
GetSessionCallback |
The callback function. |
getWriteSession(callback)
Retrieve a read/write session.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
GetWriteSessionCallback |
The callback function. |
open() → {Promise}
Opens the pool, filling it to the configured number of read and write sessions.
Returns:
| Type | Description |
|---|---|
| Promise |
Fires:
- SessionPool#event:open
release(session)
Releases session back into the pool.
Parameters:
| Name | Type | Description |
|---|---|---|
session |
Session |
The session to release. |
Fires:
- SessionPool#event:available
- SessionPool#event:session-available
- @deprecated SessionPool#event:readonly-available
- @deprecated SessionPool#event:readwrite-available
Throws:
-
For unknown sessions.
- Type
- Error
(static) formatTrace(trace) → {string}
Formats stack trace objects into Node-like stack trace.
Parameters:
| Name | Type | Description |
|---|---|---|
trace |
Array.<object> |
The trace object. |
Returns:
| Type | Description |
|---|---|
| string |