Class: ConsumerService
Defined in: packages/microservice/job-broker/src/quantification/services/consumer.service.ts:17
Implements
OnApplicationBootstrap
Constructors
Constructor
new ConsumerService(
quantificationJobModel,configSvc):ConsumerService
Defined in: packages/microservice/job-broker/src/quantification/services/consumer.service.ts:26
Construct the service with persistence and configuration dependencies.
Parameters
quantificationJobModel
Model<QuantificationJobReport>
Mongoose model to update quantification job records
configSvc
ConfigService
Nest ConfigService for RabbitMQ connectivity and queue settings
Returns
ConsumerService
Methods
onApplicationBootstrap()
onApplicationBootstrap():
Promise<void>
Defined in: packages/microservice/job-broker/src/quantification/services/consumer.service.ts:77
Initializes the consumer service and starts consuming messages from RabbitMQ upon module initialization.
Sets up the environment by loading necessary env variables, establishing a connection to RabbitMQ, and preparing the service to consume messages from the initial job queue. It ensures that all required environment variables are set, connects to RabbitMQ with retry logic, and sets up message consumption with appropriate error handling and acknowledgment.
Returns
Promise<void>
A promise that resolves when the module initialization process is complete.
Implementation of
OnApplicationBootstrap.onApplicationBootstrap
performQuantification()
performQuantification(
modelsWithConfigs):string[]
Defined in: packages/microservice/job-broker/src/quantification/services/consumer.service.ts:152
Performs quantification by invoking the scram-node-addon with the provided configurations. This method processes quantification requests by writing model data to temporary files, invoking the SCRAM CLI through the scram-node-addon, and reading the results from an output file. It handles the creation and cleanup of all temporary files used during the process.
Parameters
modelsWithConfigs
QuantifyRequest
The quantification request containing model data and configurations.
Returns
string[]
A QuantifyReport object containing the results of the quantification process.
writeNodeAddonModelFilesBase64()
writeNodeAddonModelFilesBase64(
models):string[]
Defined in: packages/microservice/job-broker/src/quantification/services/consumer.service.ts:213
Writes model data, provided as Base64 encoded strings, to temporary XML files.
Iterates over an array of model data strings, each encoded in Base64. For each model, it decodes the string into UTF-8 format and writes the resulting content to a temporary file. This is necessary for processing the model data with external tools or libraries that require file input. The temporary files are prefixed with "models-" and suffixed with ".xml" to indicate their content and format.
Parameters
models
string[]
An array of Base64 encoded strings representing the model data.
Returns
string[]
An array of strings, where each string is the path to a temporary file containing the decoded model data.
