Skip to content

Commit

Permalink
feat: unify Pool max connection size in supported Drivers (#9305)
Browse files Browse the repository at this point in the history
Added `poolSize` option everywhere to controll pool option

Closes: #3388

Co-authored-by: mortzprk <mortz.prk@gmail.com>
  • Loading branch information
mortezaPRK and mortzprk committed Sep 19, 2022
1 parent f24b262 commit 48976c2
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/data-source-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Different RDBMS-es have their own specific options.
- `maxQueryExecutionTime` - If query execution time exceed this given max execution time (in milliseconds)
then logger will log this query.

- `poolSize` - Configure maximum number of active connections is the pool.

- `namingStrategy` - Naming strategy to be used to name tables and columns in the database.

- `entityPrefix` - Prefixes with the given string all tables (or collections) on this data source.
Expand Down
5 changes: 5 additions & 0 deletions src/data-source/BaseDataSourceOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export interface BaseDataSourceOptions {
*/
readonly maxQueryExecutionTime?: number

/**
* Maximum number of clients the pool should contain.
*/
readonly poolSize?: number

/**
* Indicates if database schema should be auto created on every application launch.
* Be careful with this option and don't use this in production - otherwise you can lose production data.
Expand Down
2 changes: 2 additions & 0 deletions src/driver/aurora-mysql/AuroraMysqlConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export interface AuroraMysqlConnectionOptions
* (Default: true)
*/
readonly legacySpatialSupport?: boolean

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/aurora-postgres/AuroraPostgresConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ export interface AuroraPostgresConnectionOptions extends BaseDataSourceOptions {
readonly serviceConfigOptions?: { [key: string]: any }

readonly formatOptions?: { [key: string]: any; castParameters: boolean }

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/better-sqlite3/BetterSqlite3ConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ export interface BetterSqlite3ConnectionOptions extends BaseDataSourceOptions {
* Relative or absolute path to the native addon (better_sqlite3.node).
*/
readonly nativeBinding?: string

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/capacitor/CapacitorConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ export interface CapacitorConnectionOptions extends BaseDataSourceOptions {
| "MEMORY"
| "WAL"
| "OFF"

readonly poolSize?: never
}
1 change: 1 addition & 0 deletions src/driver/cockroachdb/CockroachDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ export class CockroachDriver implements Driver {
port: credentials.port,
ssl: credentials.ssl,
application_name: options.applicationName,
max: options.poolSize,
},
options.extra || {},
)
Expand Down
2 changes: 2 additions & 0 deletions src/driver/cordova/CordovaConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export interface CordovaConnectionOptions extends BaseDataSourceOptions {
* Storage Location
*/
readonly location: string

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/expo/ExpoConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ export interface ExpoConnectionOptions extends BaseDataSourceOptions {
* Driver module
*/
readonly driver: any

readonly poolSize?: never
}
5 changes: 0 additions & 5 deletions src/driver/mongodb/MongoConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ export interface MongoConnectionOptions extends BaseDataSourceOptions {
*/
readonly driver?: any

/**
* Set the maximum poolSize for each individual server or proxy connection.
*/
readonly poolSize?: number

/**
* Use ssl connection (needs to have a mongod server with ssl support). Default: false
*/
Expand Down
1 change: 1 addition & 0 deletions src/driver/mysql/MysqlDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ export class MysqlDriver implements Driver {
options.acquireTimeout === undefined
? {}
: { acquireTimeout: options.acquireTimeout },
{ connectionLimit: options.poolSize },
options.extra || {},
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/driver/nativescript/NativescriptConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ export interface NativescriptConnectionOptions extends BaseDataSourceOptions {
* Flags to pass to SQLite when opening the database on Android. (see https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html)
*/
readonly androidFlags?: number

readonly poolSize?: never
}
3 changes: 3 additions & 0 deletions src/driver/oracle/OracleDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ export class OracleDriver implements Driver {
password: credentials.password,
connectString: credentials.connectString,
},
{
poolMax: options.poolSize,
},
options.extra || {},
)

Expand Down
1 change: 1 addition & 0 deletions src/driver/postgres/PostgresDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ export class PostgresDriver implements Driver {
ssl: credentials.ssl,
connectionTimeoutMillis: options.connectTimeoutMS,
application_name: options.applicationName,
max: options.poolSize,
},
options.extra || {},
)
Expand Down
2 changes: 2 additions & 0 deletions src/driver/react-native/ReactNativeConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export interface ReactNativeConnectionOptions extends BaseDataSourceOptions {
* Storage Location
*/
readonly location: string

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/sap/SapConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ export interface SapConnectionOptions
*/
readonly poolErrorHandler?: (err: any) => any
}

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/spanner/SpannerConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,6 @@ export interface SpannerConnectionOptions
*/
readonly selector?: "RR" | "RANDOM" | "ORDER"
}

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/sqlite/SqliteConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ export interface SqliteConnectionOptions extends BaseDataSourceOptions {
* @see https://www.sqlite.org/wal.html
*/
readonly enableWAL?: boolean

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/sqljs/SqljsConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ export interface SqljsConnectionOptions extends BaseDataSourceOptions {
* indexedDB instead of using the synchron local storage methods in a browser environment.
*/
readonly useLocalForage?: boolean

readonly poolSize?: never
}
2 changes: 2 additions & 0 deletions src/driver/sqlserver/SqlServerConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,6 @@ export interface SqlServerConnectionOptions
*/
readonly slaves: SqlServerConnectionCredentialsOptions[]
}

readonly poolSize?: never
}

0 comments on commit 48976c2

Please sign in to comment.