Constructor
new SessionFactory(database, name, options)
Parameters:
Name | Type | Description |
---|---|---|
database |
Database |
Database object. |
name |
String |
Name of the database. |
options |
SessionPoolOptions | SessionPoolInterface |
Session pool configuration options or custom pool inteface. |
Methods
getPool() → {SessionPoolInterface}
Returns the regular session pool object.
Returns:
Type | Description |
---|---|
SessionPoolInterface |
The session pool used by current instance. |
getSession(callback)
Retrieves a session, either a regular session or a multiplexed session, based on the environment variable configuration.
If the environment variable GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS
is set to true
, the method will attempt to
retrieve a multiplexed session. Otherwise, it will retrieve a session from the regular pool.
Parameters:
Name | Type | Description |
---|---|---|
callback |
GetSessionCallback |
The callback function. |
getSessionForPartitionedOps(callback)
Retrieves a session for partitioned operations, selecting the appropriate session type based on whether multiplexed sessions are enabled.
If multiplexed sessions are enabled for partitioned ops this methods delegates the request to getSession()
, which returns
either a multiplexed session or a regular session based on the configuration.
If the multiplexed sessions are disabled, a session is retrieved from the regular session pool.
Parameters:
Name | Type | Description |
---|---|---|
callback |
GetSessionCallback |
The callback function. |
isMultiplexedEnabled() → {boolean}
Returns if a multiplexed is enabled or not.
This method returns true if multiplexed session is enabled, otherwise returns false
Returns:
Type | Description |
---|---|
boolean |
release(session)
Releases a regular session back to the session pool.
This methods does not release a multiplexed session.
It returns a session to the pool after it is no longer needed. It is a no-op for multiplexed sessions.
Parameters:
Name | Type | Description |
---|---|---|
session |
Session |
The session to be released. This should be an instance of |
Throws:
-
If the session is invalid or cannot be released.
- Type
- Error