Skip to content

Commit 1fd7a3e

Browse files
authored
feat(base-driver): add an option to skip connection test probes (#8833)
1 parent 578b90c commit 1fd7a3e

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

packages/cubejs-backend-shared/src/env.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,17 @@ const variables: Record<string, (...args: any) => any> = {
479479
return val;
480480
},
481481

482+
/**
483+
* Flag to disable driver's test connection probes
484+
*/
485+
dbDisableTestConnection: ({
486+
dataSource
487+
}: {
488+
dataSource: string,
489+
}) => (
490+
!!process.env[keyByDataSource('CUBEJS_DB_DISABLE_TEST_CONNECTION', dataSource)]
491+
),
492+
482493
/**
483494
* Database max pool size.
484495
*/
@@ -500,7 +511,7 @@ const variables: Record<string, (...args: any) => any> = {
500511
),
501512

502513
/**
503-
* Max polling interval. Currenly used in BigQuery and Databricks.
514+
* Max polling interval. Currently used in BigQuery and Databricks.
504515
* TODO: clarify this env.
505516
*/
506517
dbPollMaxInterval: ({
@@ -514,7 +525,7 @@ const variables: Record<string, (...args: any) => any> = {
514525
},
515526

516527
/**
517-
* Polling timeout. Currenly used in BigQuery, Dremio and Athena.
528+
* Polling timeout. Currently used in BigQuery, Dremio and Athena.
518529
* TODO: clarify this env.
519530
*/
520531
dbPollTimeout: ({
@@ -532,7 +543,7 @@ const variables: Record<string, (...args: any) => any> = {
532543
},
533544

534545
/**
535-
* Query timeout. Currenly used in BigQuery, Dremio, Postgres, Snowflake
546+
* Query timeout. Currently used in BigQuery, Dremio, Postgres, Snowflake
536547
* and Athena drivers and the orchestrator (queues, pre-aggs). For the
537548
* orchestrator this variable did not split by the datasource.
538549
*

packages/cubejs-base-driver/src/BaseDriver.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ const DbTypeValueMatcher: Record<string, ((v: any) => boolean)> = {
171171
* Base driver class.
172172
*/
173173
export abstract class BaseDriver implements DriverInterface {
174-
private testConnectionTimeoutValue = 10000;
174+
private readonly testConnectionTimeoutValue: number = 10000;
175175

176176
protected logger: any;
177177

178+
protected isTestConnectionDisabledFlag: boolean = false;
179+
178180
/**
179181
* Class constructor.
180182
*/
@@ -184,8 +186,14 @@ export abstract class BaseDriver implements DriverInterface {
184186
* request before determining it as not valid. Default - 10000 ms.
185187
*/
186188
testConnectionTimeout?: number,
189+
190+
/**
191+
* Flag for serverless DWHs to omit test connection probes.
192+
*/
193+
isTestConnectionDisabled?: boolean,
187194
} = {}) {
188195
this.testConnectionTimeoutValue = _options.testConnectionTimeout || 10000;
196+
this.isTestConnectionDisabledFlag = _options.isTestConnectionDisabled || false;
189197
}
190198

191199
protected informationSchemaQuery() {
@@ -680,6 +688,10 @@ export abstract class BaseDriver implements DriverInterface {
680688
query.query = `SELECT * FROM (${query.query}) AS t LIMIT ${query.limit}`;
681689
}
682690

691+
public isTestConnectionDisabled(): boolean {
692+
return !!this.isTestConnectionDisabledFlag;
693+
}
694+
683695
/**
684696
* Returns an array of signed AWS S3 URLs of the unloaded csv files.
685697
*/

0 commit comments

Comments
 (0)