mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Merge branch 'lts-3.0' into release/v3.0.2-lts
This commit is contained in:
commit
06e76ba631
3 changed files with 26 additions and 15 deletions
|
|
@ -10,12 +10,16 @@ import {
|
|||
import { SourceOptions, QueryOptions } from './types';
|
||||
import { isEmpty } from '@tooljet-plugins/common';
|
||||
|
||||
const STATEMENT_TIMEOUT = 10000;
|
||||
|
||||
export default class MssqlQueryService implements QueryService {
|
||||
private static _instance: MssqlQueryService;
|
||||
private STATEMENT_TIMEOUT;
|
||||
|
||||
constructor() {
|
||||
this.STATEMENT_TIMEOUT =
|
||||
process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT && !isNaN(Number(process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT))
|
||||
? Number(process.env.PLUGINS_SQL_DB_STATEMENT_TIMEOUT)
|
||||
: 120000;
|
||||
|
||||
if (MssqlQueryService._instance) {
|
||||
return MssqlQueryService._instance;
|
||||
}
|
||||
|
|
@ -84,13 +88,13 @@ export default class MssqlQueryService implements QueryService {
|
|||
private async executeQuery(knexInstance: Knex, query: string, sanitizedQueryParams: Record<string, any> = {}) {
|
||||
if (isEmpty(query)) throw new Error('Query is empty');
|
||||
|
||||
const result = await knexInstance.raw(query, sanitizedQueryParams).timeout(STATEMENT_TIMEOUT);
|
||||
const result = await knexInstance.raw(query, sanitizedQueryParams).timeout(this.STATEMENT_TIMEOUT);
|
||||
return result;
|
||||
}
|
||||
|
||||
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
|
||||
const knexInstance = await this.getConnection(sourceOptions, {}, false);
|
||||
await knexInstance.raw('select @@version;').timeout(STATEMENT_TIMEOUT);
|
||||
await knexInstance.raw('select @@version;').timeout(this.STATEMENT_TIMEOUT);
|
||||
knexInstance.destroy();
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ import {
|
|||
import { SourceOptions, QueryOptions } from './types';
|
||||
import { isEmpty } from '@tooljet-plugins/common';
|
||||
|
||||
const STATEMENT_TIMEOUT = 10000;
|
||||
|
||||
export default class MysqlQueryService implements QueryService {
|
||||
private static _instance: MysqlQueryService;
|
||||
private STATEMENT_TIMEOUT;
|
||||
|
||||
constructor() {
|
||||
this.STATEMENT_TIMEOUT =
|
||||
process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT && !isNaN(Number(process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT))
|
||||
? Number(process.env.PLUGINS_SQL_DB_STATEMENT_TIMEOUT)
|
||||
: 120000;
|
||||
|
||||
if (MysqlQueryService._instance) {
|
||||
return MysqlQueryService._instance;
|
||||
}
|
||||
|
|
@ -51,7 +55,7 @@ export default class MysqlQueryService implements QueryService {
|
|||
|
||||
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
|
||||
const knexInstance = await this.getConnection(sourceOptions, {}, false);
|
||||
await knexInstance.raw('select @@version;').timeout(STATEMENT_TIMEOUT);
|
||||
await knexInstance.raw('select @@version;').timeout(this.STATEMENT_TIMEOUT);
|
||||
knexInstance.destroy();
|
||||
return { status: 'ok' };
|
||||
}
|
||||
|
|
@ -77,7 +81,7 @@ export default class MysqlQueryService implements QueryService {
|
|||
private async executeQuery(knexInstance: Knex, query: string, sanitizedQueryParams: Record<string, any> = {}) {
|
||||
if (isEmpty(query)) throw new Error('Query is empty');
|
||||
|
||||
const result = await knexInstance.raw(query, sanitizedQueryParams).timeout(STATEMENT_TIMEOUT);
|
||||
const result = await knexInstance.raw(query, sanitizedQueryParams).timeout(this.STATEMENT_TIMEOUT);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ import { SourceOptions, QueryOptions } from './types';
|
|||
import knex, { Knex } from 'knex';
|
||||
import { isEmpty } from '@tooljet-plugins/common';
|
||||
|
||||
const STATEMENT_TIMEOUT = 10000;
|
||||
|
||||
export default class PostgresqlQueryService implements QueryService {
|
||||
private static _instance: PostgresqlQueryService;
|
||||
private STATEMENT_TIMEOUT;
|
||||
|
||||
constructor() {
|
||||
this.STATEMENT_TIMEOUT =
|
||||
process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT && !isNaN(Number(process.env?.PLUGINS_SQL_DB_STATEMENT_TIMEOUT))
|
||||
? Number(process.env.PLUGINS_SQL_DB_STATEMENT_TIMEOUT)
|
||||
: 120000;
|
||||
|
||||
if (PostgresqlQueryService._instance) {
|
||||
return PostgresqlQueryService._instance;
|
||||
}
|
||||
|
|
@ -51,7 +55,7 @@ export default class PostgresqlQueryService implements QueryService {
|
|||
|
||||
async testConnection(sourceOptions: SourceOptions): Promise<ConnectionTestResult> {
|
||||
const knexInstance = await this.getConnection(sourceOptions, {}, false);
|
||||
await knexInstance.raw('SELECT version();').timeout(STATEMENT_TIMEOUT);
|
||||
await knexInstance.raw('SELECT version();').timeout(this.STATEMENT_TIMEOUT);
|
||||
return { status: 'ok' };
|
||||
}
|
||||
|
||||
|
|
@ -75,9 +79,7 @@ export default class PostgresqlQueryService implements QueryService {
|
|||
|
||||
private async executeQuery(knexInstance: Knex, query: string, sanitizedQueryParams: Record<string, any> = {}) {
|
||||
if (isEmpty(query)) throw new Error('Query is empty');
|
||||
|
||||
const { rows } = await knexInstance.raw(query, sanitizedQueryParams).timeout(STATEMENT_TIMEOUT);
|
||||
|
||||
const { rows } = await knexInstance.raw(query, sanitizedQueryParams);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +102,7 @@ export default class PostgresqlQueryService implements QueryService {
|
|||
password: sourceOptions.password,
|
||||
port: sourceOptions.port,
|
||||
ssl: this.getSslConfig(sourceOptions),
|
||||
statement_timeout: this.STATEMENT_TIMEOUT,
|
||||
};
|
||||
} else if (sourceOptions.connection_type === 'string' && sourceOptions.connection_string) {
|
||||
connectionConfig = {
|
||||
|
|
@ -111,7 +114,7 @@ export default class PostgresqlQueryService implements QueryService {
|
|||
client: 'pg',
|
||||
connection: connectionConfig,
|
||||
pool: { min: 0, max: 10, acquireTimeoutMillis: 10000 },
|
||||
acquireConnectionTimeout: 10000,
|
||||
acquireConnectionTimeout: 60000,
|
||||
...this.connectionOptions(sourceOptions),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue