/** * Runs a callback once within each tenant's context for a tenant database identifier, * optionally several tenants at a time. Each tenant is entered with `runWithTenant`, and a * tenant whose database identifier is inactive throws rather than running the callback * against the wrong connection. When iterating in parallel the per-tenant failures are * collected and rethrown together as an `AggregateError` so one bad tenant does not hide the * others. This is the iteration engine shared by the `db:tenants:*` CLI commands and the * runtime tenant façade; the caller is responsible for producing the tenant list. */ export default class TenantIterator { configuration: import("../configuration.js").default; identifier: string; parallelCount: number; /** * Creates an iterator bound to a configuration and tenant database identifier. * @param {{configuration: import("../configuration.js").default, identifier: string, parallelCount?: number}} args - Tenant configuration, database identifier, and concurrency limit. */ constructor({ configuration, identifier, parallelCount }: { configuration: import("../configuration.js").default; identifier: string; parallelCount?: number; }); /** * Runs `callback` within each tenant's context and returns how many tenants were processed. * @param {Array>} tenants - Tenant descriptors to enter and process. * @param {(args: {databaseConfiguration: import("../configuration-types.js").DatabaseConfigurationType, tenant: ReturnType}) => Promise} callback - Per-tenant operation receiving the active database configuration. * @returns {Promise} - Number of processed tenants. */ run(tenants: Array>, callback: (args: { databaseConfiguration: import("../configuration-types.js").DatabaseConfigurationType; tenant: ReturnType; }) => Promise): Promise; /** * Enters one tenant's context and runs the callback, asserting the database is active first. * @param {{callback: (args: {databaseConfiguration: import("../configuration-types.js").DatabaseConfigurationType, tenant: ReturnType}) => Promise, tenant: ReturnType}} args - Tenant descriptor and operation to run in its context. * @returns {Promise} */ runTenantCallback({ callback, tenant }: { callback: (args: { databaseConfiguration: import("../configuration-types.js").DatabaseConfigurationType; tenant: ReturnType; }) => Promise; tenant: ReturnType; }): Promise; /** * Builds a human-readable label for a tenant for use in error messages. * @param {ReturnType} tenant - Tenant descriptor to identify in an error. * @returns {string} - Human-readable tenant label. */ static tenantLabel(tenant: ReturnType): string; } //# sourceMappingURL=tenant-iterator.d.ts.map