**src/assets/config.json**:
-| Key | Value(s) | Default Value | Value type | Description |
-| -------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| supervisionUrls | | [] | string \| string[] | string or strings array containing global connection URIs to OCPP-J servers |
-| supervisionUrlDistribution | round-robin/random/charging-station-affinity | charging-station-affinity | string | supervision urls distribution policy to simulated charging stations |
-| log | | {<br />"enabled": true,<br />"file": "logs/combined.log",<br />"errorFile": "logs/error.log",<br />"statisticsInterval": 60,<br />"level": "info",<br />"console": false,<br />"format": "simple",<br />"rotate": true<br />} | {<br />enabled?: boolean;<br />file?: string;<br />errorFile?: string;<br />statisticsInterval?: number;<br />level?: string;<br />console?: boolean;<br />format?: string;<br />rotate?: boolean;<br />maxFiles?: string \| number;<br />maxSize?: string \| number;<br />} | Log configuration section:<br />- _enabled_: enable logging<br />- _file_: log file relative path<br />- _errorFile_: error log file relative path<br />- _statisticsInterval_: seconds between charging stations statistics output in the logs<br />- _level_: emerg/alert/crit/error/warning/notice/info/debug [winston](https://github.com/winstonjs/winston) logging level</br >- _console_: output logs on the console<br />- _format_: [winston](https://github.com/winstonjs/winston) log format<br />- _rotate_: enable daily log files rotation<br />- _maxFiles_: maximum number of log files: https://github.com/winstonjs/winston-daily-rotate-file#options<br />- _maxSize_: maximum size of log files in bytes, or units of kb, mb, and gb: https://github.com/winstonjs/winston-daily-rotate-file#options |
-| worker | | {<br />"processType": "workerSet",<br />"startDelay": 500,<br />"elementStartDelay": 0,<br />"elementsPerWorker": 'auto',<br />"poolMinSize": 4,<br />"poolMaxSize": 16<br />} | {<br />processType?: WorkerProcessType;<br />startDelay?: number;<br />elementStartDelay?: number;<br />elementsPerWorker?: number \| 'auto' \| 'all';<br />poolMinSize?: number;<br />poolMaxSize?: number;<br />resourceLimits?: ResourceLimits;<br />} | Worker configuration section:<br />- _processType_: worker threads process type (`workerSet`/`fixedPool`/`dynamicPool`)<br />- _startDelay_: milliseconds to wait at worker threads startup (only for `workerSet` worker threads process type)<br />- _elementStartDelay_: milliseconds to wait at charging station startup<br />- _elementsPerWorker_: number of charging stations per worker threads for the `workerSet` process type (`auto` means (number of stations) / (number of CPUs) \* 1.5 if (number of stations) > (number of CPUs), otherwise 1; `all` means a unique worker will run all charging stations)<br />- _poolMinSize_: worker threads pool minimum number of threads</br >- _poolMaxSize_: worker threads pool maximum number of threads<br />- _resourceLimits_: worker threads [resource limits](https://nodejs.org/api/worker_threads.html#new-workerfilename-options) object option |
-| uiServer | | {<br />"enabled": false,<br />"type": "ws",<br />"version": "1.1",<br />"options": {<br />"host": "localhost",<br />"port": 8080<br />}<br />} | {<br />enabled?: boolean;<br />type?: ApplicationProtocol;<br />version?: ApplicationProtocolVersion;<br />options?: ServerOptions;<br />authentication?: {<br />enabled: boolean;<br />type: AuthenticationType;<br />username?: string;<br />password?: string;<br />}<br />} | UI server configuration section:<br />- _enabled_: enable UI server<br />- _type_: 'http' or 'ws'<br />- _version_: HTTP version '1.1' or '2.0'<br />- _options_: node.js net module [listen options](https://nodejs.org/api/net.html#serverlistenoptions-callback)<br />- _authentication_: authentication type configuration section |
-| performanceStorage | | {<br />"enabled": true,<br />"type": "none",<br />} | {<br />enabled?: boolean;<br />type?: string;<br />uri?: string;<br />} | Performance storage configuration section:<br />- _enabled_: enable performance storage<br />- _type_: 'jsonfile', 'mongodb' or 'none'<br />- _uri_: storage URI |
-| stationTemplateUrls | | {}[] | {<br />file: string;<br />numberOfStations: number;<br />}[] | array of charging station configuration templates URIs configuration section (charging station configuration template file name and number of stations) |
+| Key | Value(s) | Default Value | Value type | Description |
+| -------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| supervisionUrls | | [] | string \| string[] | string or strings array containing global connection URIs to OCPP-J servers |
+| supervisionUrlDistribution | round-robin/random/charging-station-affinity | charging-station-affinity | string | supervision urls distribution policy to simulated charging stations |
+| log | | {<br />"enabled": true,<br />"file": "logs/combined.log",<br />"errorFile": "logs/error.log",<br />"statisticsInterval": 60,<br />"level": "info",<br />"console": false,<br />"format": "simple",<br />"rotate": true<br />} | {<br />enabled?: boolean;<br />file?: string;<br />errorFile?: string;<br />statisticsInterval?: number;<br />level?: string;<br />console?: boolean;<br />format?: string;<br />rotate?: boolean;<br />maxFiles?: string \| number;<br />maxSize?: string \| number;<br />} | Log configuration section:<br />- _enabled_: enable logging<br />- _file_: log file relative path<br />- _errorFile_: error log file relative path<br />- _statisticsInterval_: seconds between charging stations statistics output in the logs<br />- _level_: emerg/alert/crit/error/warning/notice/info/debug [winston](https://github.com/winstonjs/winston) logging level</br >- _console_: output logs on the console<br />- _format_: [winston](https://github.com/winstonjs/winston) log format<br />- _rotate_: enable daily log files rotation<br />- _maxFiles_: maximum number of log files: https://github.com/winstonjs/winston-daily-rotate-file#options<br />- _maxSize_: maximum size of log files in bytes, or units of kb, mb, and gb: https://github.com/winstonjs/winston-daily-rotate-file#options |
+| worker | | {<br />"processType": "workerSet",<br />"startDelay": 500,<br />"elementAddDelay": 0,<br />"elementsPerWorker": 'auto',<br />"poolMinSize": 4,<br />"poolMaxSize": 16<br />} | {<br />processType?: WorkerProcessType;<br />startDelay?: number;<br />elementAddDelay?: number;<br />elementsPerWorker?: number \| 'auto' \| 'all';<br />poolMinSize?: number;<br />poolMaxSize?: number;<br />resourceLimits?: ResourceLimits;<br />} | Worker configuration section:<br />- _processType_: worker threads process type (`workerSet`/`fixedPool`/`dynamicPool`)<br />- _startDelay_: milliseconds to wait at worker threads startup (only for `workerSet` worker threads process type)<br />- _elementAddDelay_: milliseconds to wait between charging station add<br />- _elementsPerWorker_: number of charging stations per worker threads for the `workerSet` process type (`auto` means (number of stations) / (number of CPUs) \* 1.5 if (number of stations) > (number of CPUs), otherwise 1; `all` means a unique worker will run all charging stations)<br />- _poolMinSize_: worker threads pool minimum number of threads</br >- _poolMaxSize_: worker threads pool maximum number of threads<br />- _resourceLimits_: worker threads [resource limits](https://nodejs.org/api/worker_threads.html#new-workerfilename-options) object option |
+| uiServer | | {<br />"enabled": false,<br />"type": "ws",<br />"version": "1.1",<br />"options": {<br />"host": "localhost",<br />"port": 8080<br />}<br />} | {<br />enabled?: boolean;<br />type?: ApplicationProtocol;<br />version?: ApplicationProtocolVersion;<br />options?: ServerOptions;<br />authentication?: {<br />enabled: boolean;<br />type: AuthenticationType;<br />username?: string;<br />password?: string;<br />}<br />} | UI server configuration section:<br />- _enabled_: enable UI server<br />- _type_: 'http' or 'ws'<br />- _version_: HTTP version '1.1' or '2.0'<br />- _options_: node.js net module [listen options](https://nodejs.org/api/net.html#serverlistenoptions-callback)<br />- _authentication_: authentication type configuration section |
+| performanceStorage | | {<br />"enabled": true,<br />"type": "none",<br />} | {<br />enabled?: boolean;<br />type?: string;<br />uri?: string;<br />} | Performance storage configuration section:<br />- _enabled_: enable performance storage<br />- _type_: 'jsonfile', 'mongodb' or 'none'<br />- _uri_: storage URI |
+| stationTemplateUrls | | {}[] | {<br />file: string;<br />numberOfStations: number;<br />}[] | array of charging station configuration templates URIs configuration section (charging station configuration template file name and number of stations) |
#### Worker process model
workerConfiguration.processType!,
{
workerStartDelay: workerConfiguration.startDelay,
- elementStartDelay: workerConfiguration.elementStartDelay,
+ elementAddDelay: workerConfiguration.elementAddDelay,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
poolMaxSize: workerConfiguration.poolMaxSize!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
hashId: string
templateIndex: number
templateName: string
- /** @deprecated Use hashId instead */
+ /** @deprecated Use `hashId` instead. */
infoHash?: string
chargingStationId?: string
chargeBoxSerialNumber?: string
registrationMaxRetries?: number
enableStatistics?: boolean
remoteAuthorization?: boolean
- /** @deprecated Replaced by remoteAuthorization */
+ /** @deprecated Replaced by remoteAuthorization. */
mustAuthorizeAtRemoteStart?: boolean
- /** @deprecated Replaced by ocppStrictCompliance */
+ /** @deprecated Replaced by ocppStrictCompliance. */
payloadSchemaValidation?: boolean
amperageLimitationOcppKey?: string
amperageLimitationUnit?: AmpereUnits
processType?: WorkerProcessType
startDelay?: number
elementsPerWorker?: ElementsPerWorkerType
+ /** @deprecated Use `elementAddDelay` instead. */
elementStartDelay?: number
+ elementAddDelay?: number
poolMinSize?: number
poolMaxSize?: number
resourceLimits?: ResourceLimits
worker?: WorkerConfiguration
uiServer?: UIServerConfiguration
performanceStorage?: StorageConfiguration
- /** @deprecated Moved to charging station template */
+ /** @deprecated Moved to charging station template. */
autoReconnectMaxRetries?: number
/** @deprecated Moved to worker configuration section. */
workerProcess?: WorkerProcessType
/** @deprecated Moved to worker configuration section. */
workerStartDelay?: number
/** @deprecated Moved to worker configuration section. */
- elementStartDelay?: number
+ elementAddDelay?: number
/** @deprecated Moved to worker configuration section. */
workerPoolMinSize?: number
/** @deprecated Moved to worker configuration section. */
type WorkerConfiguration
} from '../types/index.js'
import {
- DEFAULT_ELEMENT_START_DELAY,
+ DEFAULT_ELEMENT_ADD_DELAY,
DEFAULT_POOL_MAX_SIZE,
DEFAULT_POOL_MIN_SIZE,
DEFAULT_WORKER_START_DELAY,
processType: WorkerProcessType.workerSet,
startDelay: DEFAULT_WORKER_START_DELAY,
elementsPerWorker: 'auto',
- elementStartDelay: DEFAULT_ELEMENT_START_DELAY,
+ elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY,
poolMinSize: DEFAULT_POOL_MIN_SIZE,
poolMaxSize: DEFAULT_POOL_MAX_SIZE
}
+
const deprecatedWorkerConfiguration: WorkerConfiguration = {
...(hasOwnProp(Configuration.getConfigurationData(), 'workerProcess') && {
processType: Configuration.getConfigurationData()?.workerProcess
...(hasOwnProp(Configuration.getConfigurationData(), 'chargingStationsPerWorker') && {
elementsPerWorker: Configuration.getConfigurationData()?.chargingStationsPerWorker
}),
- ...(hasOwnProp(Configuration.getConfigurationData(), 'elementStartDelay') && {
- elementStartDelay: Configuration.getConfigurationData()?.elementStartDelay
+ ...(hasOwnProp(Configuration.getConfigurationData(), 'elementAddDelay') && {
+ elementAddDelay: Configuration.getConfigurationData()?.elementAddDelay
+ }),
+ ...(hasOwnProp(Configuration.getConfigurationData()?.worker, 'elementStartDelay') && {
+ elementAddDelay: Configuration.getConfigurationData()?.worker?.elementStartDelay
}),
...(hasOwnProp(Configuration.getConfigurationData(), 'workerPoolMinSize') && {
poolMinSize: Configuration.getConfigurationData()?.workerPoolMinSize
`Use '${ConfigurationSection.worker}' section to define the number of element(s) per worker instead`
)
Configuration.warnDeprecatedConfigurationKey(
- 'elementStartDelay',
+ 'elementAddDelay',
undefined,
- `Use '${ConfigurationSection.worker}' section to define the worker's element start delay instead`
+ `Use '${ConfigurationSection.worker}' section to define the worker's element add delay instead`
)
Configuration.warnDeprecatedConfigurationKey(
'workerPoolMinSize',
ConfigurationSection.worker,
'Not publicly exposed to end users'
)
+ Configuration.warnDeprecatedConfigurationKey(
+ 'elementStartDelay',
+ ConfigurationSection.worker,
+ "Use 'elementAddDelay' instead"
+ )
if (
Configuration.getConfigurationData()?.worker?.processType ===
('staticPool' as WorkerProcessType)
export const workerSetVersion = '1.0.1'
-export const DEFAULT_ELEMENT_START_DELAY = 0
+export const DEFAULT_ELEMENT_ADD_DELAY = 0
export const DEFAULT_WORKER_START_DELAY = 500
export const DEFAULT_POOL_MIN_SIZE = Math.floor(availableParallelism() / 2)
export const DEFAULT_POOL_MAX_SIZE = Math.round(availableParallelism() * 1.5)
export const DEFAULT_WORKER_OPTIONS: WorkerOptions = Object.freeze({
workerStartDelay: DEFAULT_WORKER_START_DELAY,
- elementStartDelay: DEFAULT_ELEMENT_START_DELAY,
+ elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY,
poolMinSize: DEFAULT_POOL_MIN_SIZE,
poolMaxSize: DEFAULT_POOL_MAX_SIZE,
elementsPerWorker: DEFAULT_ELEMENTS_PER_WORKER,
await this.pool.execute(elementData)
// Start element sequentially to optimize memory at startup
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.workerOptions.elementStartDelay! > 0 &&
+ this.workerOptions.elementAddDelay! > 0 &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (await sleep(randomizeDelay(this.workerOptions.elementStartDelay!)))
+ (await sleep(randomizeDelay(this.workerOptions.elementAddDelay!)))
}
}
await this.pool.execute(elementData)
// Start element sequentially to optimize memory at startup
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.workerOptions.elementStartDelay! > 0 &&
+ this.workerOptions.elementAddDelay! > 0 &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (await sleep(randomizeDelay(this.workerOptions.elementStartDelay!)))
+ (await sleep(randomizeDelay(this.workerOptions.elementAddDelay!)))
}
}
++workerSetElement.numberOfWorkerElements
// Add element sequentially to optimize memory at startup
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- if (this.workerOptions.elementStartDelay! > 0) {
+ if (this.workerOptions.elementAddDelay! > 0) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- await sleep(randomizeDelay(this.workerOptions.elementStartDelay!))
+ await sleep(randomizeDelay(this.workerOptions.elementAddDelay!))
}
}
export interface WorkerOptions {
workerStartDelay?: number
- elementStartDelay?: number
+ elementAddDelay?: number
poolMaxSize: number
poolMinSize: number
elementsPerWorker?: number
export type { WorkerAbstract } from './WorkerAbstract.js'
export {
- DEFAULT_ELEMENT_START_DELAY,
+ DEFAULT_ELEMENT_ADD_DELAY,
DEFAULT_POOL_MAX_SIZE,
DEFAULT_POOL_MIN_SIZE,
DEFAULT_WORKER_START_DELAY