UNPKG

bigquery-client

Version:

A feature-rich Node.js client for Google BigQuery with support for CRUD operations, transactions, query building, and advanced features like aggregate functions, pagination, and logging.

64 lines (63 loc) 2.28 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pool = void 0; const errors_1 = require("../errors"); const constants_1 = require("../config/constants"); class Pool { constructor(config = {}) { this.config = Object.assign(Object.assign({}, constants_1.DEFAULT_POOL_CONFIG), config); this.metrics = { activeConnections: 0, waitingRequests: 0, totalQueries: 0 }; } acquire() { return __awaiter(this, void 0, void 0, function* () { if (this.metrics.activeConnections >= this.config.max) { throw new errors_1.ConnectionError('Connection pool exhausted'); } this.metrics.activeConnections++; this.metrics.totalQueries++; // Implement connection acquisition logic return {}; }); } release(connection) { return __awaiter(this, void 0, void 0, function* () { this.metrics.activeConnections--; // Implement connection release logic }); } getMetrics() { return this.metrics; } healthCheck() { return __awaiter(this, void 0, void 0, function* () { try { // Implement health check logic return true; } catch (error) { return false; } }); } reset() { this.metrics = { activeConnections: 0, waitingRequests: 0, totalQueries: 0 }; } } exports.Pool = Pool;