SessionPool

SessionPool

  • @deprecated Session pool is deprecated and will be removed in a future release. Multiplexed sessions are now used for all operations by default, eliminating the need for session pooling. Class used to manage connections to Spanner.

You don't need to use this class directly, connections will be handled for you.

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.

Deprecated: Use getSession instead.

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.

Deprecated: Use getSession instead.

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.

Deprecated: Session pool is deprecated and will be removed in a future release.

Parameters:
Name Type Description
trace Array.<object>

The trace object.

Returns:
Type Description
string