@qualithm/arrow-flight-sql-js - v0.4.3
    Preparing search index...

    Class FlightSqlPool

    Connection pool for FlightSqlClient instances.

    Manages a pool of connections to a Flight SQL server, handling:

    • Connection reuse to reduce overhead
    • Automatic scaling between min and max connections
    • Health checking to ensure connection validity
    • Graceful shutdown with connection draining
    const pool = new FlightSqlPool({
    host: "localhost",
    port: 50051,
    tls: false,
    auth: { type: "bearer", token: "my-token" }
    }, {
    minConnections: 2,
    maxConnections: 10,
    idleTimeoutMs: 30000
    })

    await pool.initialize()

    // Acquire a connection
    const client = await pool.acquire()
    try {
    const result = await client.query("SELECT 1")
    // Use result...
    } finally {
    pool.release(client)
    }

    // Or use withConnection for automatic release
    await pool.withConnection(async (client) => {
    const result = await client.query("SELECT 1")
    // Use result...
    })

    await pool.close()
    Index

    Constructors

    Accessors

    • get isClosed(): boolean

      Check if the pool is closed

      Returns boolean

    • get isInitialized(): boolean

      Check if the pool is initialized and ready

      Returns boolean

    Methods

    • Acquire a connection from the pool.

      Returns Promise<FlightSqlClient>

      If no connection becomes available within acquireTimeoutMs

      If pool is closing or closed

    • Close the pool and all connections gracefully. Waits for active connections to be released.

      Parameters

      • forceTimeoutMs: number = 30_000

        Force close after this timeout (default: 30000)

      Returns Promise<void>

    • Initialize the pool and create minimum connections.

      Returns Promise<void>

      If initial connections cannot be established

    • Execute a function with a pooled connection, automatically releasing it.

      Type Parameters

      • T

      Parameters

      • fn: (client: FlightSqlClient) => Promise<T>

        Function to execute with the connection

      Returns Promise<T>

      The result of the function

      const result = await pool.withConnection(async (client) => {
      return await client.query("SELECT * FROM users")
      })
    • Execute a function with retry logic and automatic connection management.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      The result of the function