2020 */
2121import * as path from 'path' ;
2222import { EventEmitter } from 'events' ;
23+
2324import { Pool as MySQLPool } from 'mysql' ;
2425import { Pool as PgPool } from 'pg' ;
26+
2527import { Encoding } from './Encoding' ;
2628
2729export default class Conversion {
@@ -43,7 +45,7 @@ export default class Conversion {
4345 /**
4446 * V8 memory limit of the loader process.
4547 */
46- public _loaderMaxOldSpaceSize : number | string ;
48+ public readonly _loaderMaxOldSpaceSize : number | string ;
4749
4850 /**
4951 * Maximal amount of simultaneous connections to your MySQL and PostgreSQL servers each.
@@ -113,7 +115,7 @@ export default class Conversion {
113115 /**
114116 * The timestamp, at which the migration began.
115117 */
116- public _timeBegin : Date ;
118+ public readonly _timeBegin : Date ;
117119
118120 /**
119121 * Current version of source (MySQL) db.
@@ -163,7 +165,7 @@ export default class Conversion {
163165 /**
164166 * An array of data chunks.
165167 */
166- public readonly _dataPool : any [ ] ;
168+ public readonly _dataPool : object [ ] ;
167169
168170 /**
169171 * A flag, that indicates if Nmig currently runs in test mode.
@@ -201,6 +203,11 @@ export default class Conversion {
201203 */
202204 public readonly _streamsHighWaterMark : number ;
203205
206+ /**
207+ * Number of data-loader processes that will run simultaneously.
208+ */
209+ public readonly _numberOfSimultaneouslyRunningLoaderProcesses : string | number ;
210+
204211 /**
205212 * Constructor.
206213 */
@@ -226,24 +233,41 @@ export default class Conversion {
226233 this . _dataPool = [ ] ;
227234 this . _dicTables = Object . create ( null ) ;
228235 this . _mySqlDbName = this . _sourceConString . database ;
229- this . _streamsHighWaterMark = this . _config . streams_high_water_mark === undefined ? 16384 : + this . _config . streams_high_water_mark ;
236+
237+ this . _streamsHighWaterMark = this . _config . streams_high_water_mark === undefined
238+ ? 16384
239+ : + this . _config . streams_high_water_mark ;
230240
231241 this . _schema = this . _config . schema === undefined || this . _config . schema === ''
232242 ? this . _mySqlDbName
233243 : this . _config . schema ;
234244
235- this . _maxEachDbConnectionPoolSize = this . _config . max_each_db_connection_pool_size !== undefined && Conversion . _isIntNumeric ( this . _config . max_each_db_connection_pool_size )
245+ const isValidMaxEachDbConnectionPoolSize : boolean = this . _config . max_each_db_connection_pool_size !== undefined
246+ && Conversion . _isIntNumeric ( this . _config . max_each_db_connection_pool_size ) ;
247+
248+ this . _maxEachDbConnectionPoolSize = isValidMaxEachDbConnectionPoolSize
236249 ? + this . _config . max_each_db_connection_pool_size
237250 : 20 ;
238251
252+ this . _maxEachDbConnectionPoolSize = this . _maxEachDbConnectionPoolSize > 0 ? this . _maxEachDbConnectionPoolSize : 20 ;
239253 this . _runsInTestMode = false ;
240254 this . _eventEmitter = null ;
241255 this . _migrationCompletedEvent = 'migrationCompleted' ;
242- this . _removeTestResources = this . _config . remove_test_resources === undefined ? true : this . _config . remove_test_resources ;
243- this . _maxEachDbConnectionPoolSize = this . _maxEachDbConnectionPoolSize > 0 ? this . _maxEachDbConnectionPoolSize : 20 ;
244- this . _loaderMaxOldSpaceSize = this . _config . loader_max_old_space_size ;
245- this . _loaderMaxOldSpaceSize = Conversion . _isIntNumeric ( this . _loaderMaxOldSpaceSize ) ? this . _loaderMaxOldSpaceSize : 'DEFAULT' ;
256+
257+ this . _removeTestResources = this . _config . remove_test_resources === undefined
258+ ? true
259+ : this . _config . remove_test_resources ;
260+
261+ this . _numberOfSimultaneouslyRunningLoaderProcesses = Conversion . _isIntNumeric ( this . _config . number_of_simultaneously_running_loader_processes )
262+ ? + this . _config . number_of_simultaneously_running_loader_processes
263+ : 'DEFAULT' ;
264+
265+ this . _loaderMaxOldSpaceSize = Conversion . _isIntNumeric ( this . _config . loader_max_old_space_size )
266+ ? + this . _config . loader_max_old_space_size
267+ : 'DEFAULT' ;
268+
246269 this . _migrateOnlyData = this . _config . migrate_only_data === undefined ? false : this . _config . migrate_only_data ;
270+
247271 this . _delimiter = this . _config . delimiter !== undefined && this . _config . delimiter . length === 1
248272 ? this . _config . delimiter
249273 : ',' ;
0 commit comments