UNPKG

@medflyt/test-db-service

Version:

Developer tool to instantly provision test PostgreSQL databases from a template

44 lines 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PostgresClusterCollection = void 0; const PostgresClusterInstance_1 = require("./PostgresClusterInstance"); /** * Manages multiple PostgreSQL clusters (A separate cluster for each PostgreSQL * version) */ class PostgresClusterCollection { constructor() { this.clusters = new Map(); } async getPostgresUrl(postgresVersion) { const existing = this.clusters.get(postgresVersion); if (existing !== undefined) { return await existing.getPostgresUrl(); } else { const newCluster = new PostgresClusterInstance_1.PostgresClusterInstance(postgresVersion); this.clusters.set(postgresVersion, newCluster); return await newCluster.getPostgresUrl(); } } async getPostgresClusterUrls() { const result = []; for (const [postgresVersion, cluster] of this.clusters) { const url = await cluster.getPostgresUrl(); result.push({ postgresVersion: postgresVersion, url: url }); } return result; } /** * Shutdown and delete the cluster */ async close() { const instances = [...this.clusters.values()]; await Promise.all(instances.map(i => i.close())); } } exports.PostgresClusterCollection = PostgresClusterCollection; //# sourceMappingURL=PostgresClusterCollection.js.map