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

[kCheckedOut]

[kCheckedOut]: number
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

[kMetrics]

internal

Optional [kMinPoolSizeTimer]

[kMinPoolSizeTimer]: Timeout
internal

[kPermits]

[kPermits]: number

An integer expressing how many total connections are permitted

internal

[kProcessingWaitQueue]

[kProcessingWaitQueue]: boolean
internal

[kServiceGenerations]

[kServiceGenerations]: Map<string, number>

A map of generations to service ids

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
  • An integer expressing how many connections are currently available in the pool.

    Returns返回number

currentCheckedOutCount

  • get currentCheckedOutCount(): number

generation

  • get generation(): number

loadBalanced

  • get loadBalanced(): boolean

serviceGenerations

  • get serviceGenerations(): Map<string, number>

totalConnectionCount

  • get totalConnectionCount(): number
  • An integer expressing how many total connections (active + in use) the pool currently has

    Returns返回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 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.

    Parameters参数

    Returns返回void

close

emit

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

    • EventKey: "commandStarted" | "commandSucceeded" | "commandFailed" | "clusterTimeReceived" | "pinned" | "unpinned" | "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" | "pinned" | "unpinned" | "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" | "pinned" | "unpinned" | "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" | "pinned" | "unpinned" | "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" | "pinned" | "unpinned" | "connectionPoolCreated" | "connectionPoolClosed" | "connectionPoolCleared" | "connectionCreated" | "connectionReady" | "connectionClosed" | "connectionCheckOutStarted" | "connectionCheckOutFailed" | "connectionCheckedOut" | "connectionCheckedIn"

    Parameters参数

    • Optional event: string | symbol | EventKey

    Returns返回ConnectionPool

removeListener

setMaxListeners

Private waitQueueErrorMetrics

  • waitQueueErrorMetrics(): string

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

    remarks

    When in load balancer mode, connections can be pinned to cursors or transactions. In these cases we pass the connection in to this method to ensure it is used and a new connection is not checked out.

    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