Extends
- EventEmitter
Methods
_maintain() → {void}
Maintains the multiplexed session by periodically refreshing it.
This method sets up a periodic refresh interval for maintaining the session. The interval duration is determined by the @param refreshRate option, which is provided in days. The default value is 7 days.
Returns:
| Type | Description |
|---|---|
| void |
This method does not return any value. |
Throws:
-
If the multiplexed session creation fails in
_createSession, the error is caught and ignored. This is because the currently active multiplexed session has a 30-day expiry, providing the maintainer with four opportunities (one every 7 days) to refresh the active session.Hence, if the
_createSessionfails here, the system will either simply retry at the next interval or upon the next user request if the session expires. - Type
- Error
close()
Closes the multiplexed session by stopping the periodic refresh interval.
createSession()
Creates a new multiplexed session and manages its maintenance.
This method initiates the session creation process by calling the _createSession method, which returns a Promise.
Errors are silently swallowed here to prevent unhandled promise rejections or application crashes during background operations.
getSession(callback) → {void}
Retrieves a session asynchronously and invokes a callback with the session details.
Note: The callback receives (null, session). To prevent unnecessary allocations on
read query paths, a Transaction is not created here; callers requiring a read-write
transaction instantiate it via session.transaction().
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
GetSessionCallback |
The callback to be invoked once the session is acquired or an error occurs. |
Returns:
| Type | Description |
|---|---|
| void |
This method does not return any value, as it operates asynchronously and relies on the callback. |
getSessionSync() → {Session|null}
Synchronously returns the cached multiplexed session if available, or null if no session is currently cached.
Returns:
| Type | Description |
|---|---|
| Session | null |
The cached multiplexed session or null. |