Skip to content

Commit 6dc48f8

Browse files
authored
feat: connection validation and logging (#6233)
1 parent 2cff4b5 commit 6dc48f8

File tree

27 files changed

+272
-23
lines changed

27 files changed

+272
-23
lines changed

packages/cubejs-athena-driver/src/AthenaDriver.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,17 @@ export class AthenaDriver extends BaseDriver implements DriverInterface {
8787
* Max pool size value for the [cube]<-->[db] pool.
8888
*/
8989
maxPoolSize?: number,
90+
91+
/**
92+
* Time to wait for a response from a connection after validation
93+
* request before determining it as not valid. Default - 10000 ms.
94+
*/
95+
testConnectionTimeout?: number,
9096
} = {},
9197
) {
92-
super();
98+
super({
99+
testConnectionTimeout: config.testConnectionTimeout,
100+
});
93101

94102
const dataSource =
95103
config.dataSource ||

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,21 @@ const DbTypeValueMatcher = {
121121
* Base driver class.
122122
*/
123123
export abstract class BaseDriver implements DriverInterface {
124+
private testConnectionTimeoutValue = 10000;
125+
124126
protected logger: any;
125127

126128
/**
127129
* Class constructor.
128130
*/
129-
public constructor(_options = {}) {
130-
//
131+
public constructor(_options: {
132+
/**
133+
* Time to wait for a response from a connection after validation
134+
* request before determining it as not valid. Default - 10000 ms.
135+
*/
136+
testConnectionTimeout?: number,
137+
} = {}) {
138+
this.testConnectionTimeoutValue = _options.testConnectionTimeout || 10000;
131139
}
132140

133141
protected informationSchemaQuery() {
@@ -312,7 +320,7 @@ export abstract class BaseDriver implements DriverInterface {
312320
}
313321

314322
public testConnectionTimeout() {
315-
return 10000;
323+
return this.testConnectionTimeoutValue;
316324
}
317325

318326
public async downloadTable(table: string, _options: ExternalDriverCompatibilities): Promise<DownloadTableMemoryData | DownloadTableCSVData> {

packages/cubejs-bigquery-driver/src/BigQueryDriver.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,17 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
7777
* Max pool size value for the [cube]<-->[db] pool.
7878
*/
7979
maxPoolSize?: number,
80+
81+
/**
82+
* Time to wait for a response from a connection after validation
83+
* request before determining it as not valid. Default - 10000 ms.
84+
*/
85+
testConnectionTimeout?: number,
8086
} = {}
8187
) {
82-
super();
88+
super({
89+
testConnectionTimeout: config.testConnectionTimeout,
90+
});
8391

8492
const dataSource =
8593
config.dataSource ||

packages/cubejs-clickhouse-driver/src/ClickHouseDriver.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,26 @@ export class ClickHouseDriver extends BaseDriver implements DriverInterface {
7777
*/
7878
public constructor(
7979
config: ClickHouseDriverOptions & {
80+
/**
81+
* Data source name.
82+
*/
8083
dataSource?: string,
84+
85+
/**
86+
* Max pool size value for the [cube]<-->[db] pool.
87+
*/
8188
maxPoolSize?: number,
89+
90+
/**
91+
* Time to wait for a response from a connection after validation
92+
* request before determining it as not valid. Default - 10000 ms.
93+
*/
94+
testConnectionTimeout?: number,
8295
} = {},
8396
) {
84-
super();
97+
super({
98+
testConnectionTimeout: config.testConnectionTimeout,
99+
});
85100

86101
const dataSource =
87102
config.dataSource ||

packages/cubejs-databricks-jdbc-driver/src/DatabricksDriver.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ export class DatabricksDriver extends JDBCDriver {
176176
* Max pool size value for the [cube]<-->[db] pool.
177177
*/
178178
maxPoolSize?: number,
179+
180+
/**
181+
* Time to wait for a response from a connection after validation
182+
* request before determining it as not valid. Default - 10000 ms.
183+
*/
184+
testConnectionTimeout?: number,
179185
} = {},
180186
) {
181187
const dataSource =

packages/cubejs-dremio-driver/driver/DremioDriver.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class DremioDriver extends BaseDriver {
4040
* Class constructor.
4141
*/
4242
constructor(config = {}) {
43-
super();
43+
super({
44+
testConnectionTimeout: config.testConnectionTimeout,
45+
});
4446

4547
const dataSource =
4648
config.dataSource ||

packages/cubejs-druid-driver/src/DruidDriver.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,26 @@ export class DruidDriver extends BaseDriver {
4040
*/
4141
public constructor(
4242
config: DruidDriverConfiguration & {
43+
/**
44+
* Data source name.
45+
*/
4346
dataSource?: string,
47+
48+
/**
49+
* Max pool size value for the [cube]<-->[db] pool.
50+
*/
4451
maxPoolSize?: number,
52+
53+
/**
54+
* Time to wait for a response from a connection after validation
55+
* request before determining it as not valid. Default - 10000 ms.
56+
*/
57+
testConnectionTimeout?: number,
4558
} = {}
4659
) {
47-
super();
60+
super({
61+
testConnectionTimeout: config.testConnectionTimeout,
62+
});
4863

4964
const dataSource =
5065
config.dataSource ||

packages/cubejs-elasticsearch-driver/driver/ElasticSearchDriver.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class ElasticSearchDriver extends BaseDriver {
2828
* Class constructor.
2929
*/
3030
constructor(config = {}) {
31-
super();
31+
super({
32+
testConnectionTimeout: config.testConnectionTimeout,
33+
});
3234

3335
const dataSource =
3436
config.dataSource ||

packages/cubejs-firebolt-driver/src/FireboltDriver.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,21 @@ export class FireboltDriver extends BaseDriver implements DriverInterface {
6060
*/
6161
public constructor(
6262
config: Partial<FireboltDriverConfiguration> & {
63+
/**
64+
* Data source name.
65+
*/
6366
dataSource?: string,
67+
68+
/**
69+
* Max pool size value for the [cube]<-->[db] pool.
70+
*/
6471
maxPoolSize?: number,
72+
73+
/**
74+
* Time to wait for a response from a connection after validation
75+
* request before determining it as not valid. Default - 10000 ms.
76+
*/
77+
testConnectionTimeout?: number,
6578
} = {},
6679
) {
6780
super(config);

packages/cubejs-hive-driver/driver/HiveDriver.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class HiveDriver extends BaseDriver {
6262
* Class constructor.
6363
*/
6464
constructor(config = {}) {
65-
super();
65+
super({
66+
testConnectionTimeout: config.testConnectionTimeout,
67+
});
6668

6769
const dataSource =
6870
config.dataSource ||

0 commit comments

Comments
 (0)