Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConnectionPool

A pool of connections which dynamically resizes, and emit events related to pool activity

internal

Hierarchy

Index

Constructors

constructor

Events

Static Readonly CONNECTION_CHECKED_IN

CONNECTION_CHECKED_IN: "connectionCheckedIn" = ...

Emitted each time a connection is successfully checked into the connection pool

Static Readonly CONNECTION_CHECKED_OUT

CONNECTION_CHECKED_OUT: "connectionCheckedOut" = ...

Emitted each time a connection is successfully checked out of the connection pool

Static Readonly CONNECTION_CHECK_OUT_FAILED

CONNECTION_CHECK_OUT_FAILED: "connectionCheckOutFailed" = ...

Emitted when an attempt to check out a connection fails

Static Readonly CONNECTION_CHECK_OUT_STARTED

CONNECTION_CHECK_OUT_STARTED: "connectionCheckOutStarted" = ...

Emitted when an attempt to check out a connection begins

Static Readonly CONNECTION_CLOSED

CONNECTION_CLOSED: "connectionClosed" = ...

Emitted when a connection is closed

Static Readonly CONNECTION_CREATED

CONNECTION_CREATED: "connectionCreated" = ...

Emitted when a connection is created.

Static Readonly CONNECTION_POOL_CLEARED

CONNECTION_POOL_CLEARED: "connectionPoolCleared" = ...

Emitted each time the connection pool is cleared and it's generation incremented

Static Readonly CONNECTION_POOL_CLOSED

CONNECTION_POOL_CLOSED: "connectionPoolClosed" = ...

Emitted once when the connection pool is closed

Static Readonly CONNECTION_POOL_CREATED

CONNECTION_POOL_CREATED: "connectionPoolCreated" = ...

Emitted when the connection pool is created.

Static Readonly CONNECTION_READY

CONNECTION_READY: "connectionReady" = ...

Emitted when a connection becomes established, and is ready to use

Properties

[kCancellationToken]

[kCancellationToken]: CancellationToken
internal

[kConnectionCounter]

[kConnectionCounter]: Generator<number, any, unknown>
internal

[kConnections]

[kConnections]: Denque<Connection>
internal

[kGeneration]

[kGeneration]: number

An integer representing the SDAM generation of the pool

internal

[kLogger]

[kLogger]: Logger
internal

Optional [kMinPoolSizeTimer]

[kMinPoolSizeTimer]: Timeout
internal

[kPermits]

[kPermits]: number

An integer expressing how many total connections are permitted

internal

[kWaitQueue]

[kWaitQueue]: Denque<WaitQueueMember>
internal

closed

closed: boolean

options

options: Readonly<ConnectionPoolOptions>

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

address

  • get address(): string

availableConnectionCount

  • get availableConnectionCount(): number

generation

  • get generation(): number

totalConnectionCount

  • get totalConnectionCount(): number

waitQueueSize

  • get waitQueueSize(): number

Methods

addListener

checkIn

checkOut

  • Check a connection out of this pool. The connection will continue to be tracked, but no reference to it will be held by the pool. This means that if a connection is checked out it MUST be checked back in or explicitly destroyed by the new owner.

    Parameters

    Returns void

clear

  • clear(): void
  • Clear the pool

    Pool reset is handled by incrementing the pool's generation count. Any existing connection of a previous generation will eventually be pruned during subsequent checkouts.

    Returns void

close

emit

  • emit<EventKey>(event: symbol | EventKey, ...args: Parameters<ConnectionPoolEvents[EventKey]>): boolean
  • Type parameters

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters

    Returns boolean

eventNames

  • eventNames(): string[]

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount<EventKey>(type: string | symbol | EventKey): number
  • Type parameters

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters

    • type: string | symbol | EventKey

    Returns number

listeners

  • Type parameters

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters

    • event: string | symbol | EventKey

    Returns ConnectionPoolEvents[EventKey][]

off

on

once

prependListener

prependOnceListener

rawListeners

  • Type parameters

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters

    • event: string | symbol | EventKey

    Returns ConnectionPoolEvents[EventKey][]

removeAllListeners

  • removeAllListeners<EventKey>(event?: string | symbol | EventKey): ConnectionPool
  • Type parameters

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters

    • Optional event: string | symbol | EventKey

    Returns ConnectionPool

removeListener

setMaxListeners

withConnection

  • Runs a lambda with an implicitly checked out connection, checking that connection back in when the lambda has completed by calling back.

    NOTE: please note the required signature of fn

    Parameters

    Returns void

Static getEventListener

  • getEventListener(emitter: DOMEventTarget | EventEmitter, name: string | symbol): Function[]
  • Returns a list listener for a specific emitter event name.

    Parameters

    • emitter: DOMEventTarget | EventEmitter
    • name: string | symbol

    Returns Function[]

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

Generated using TypeDoc