Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
### Fixed
- Ensure trimmable characters are checked at pool initialization.
### Fixed
- Ensure trimmable characters are checked at pool initialization.
+- Fix message id integer overflow.
* When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.
*/
protected promiseMap: Map<
* When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.
*/
protected promiseMap: Map<
PromiseWorkerResponseWrapper<Worker, Response>
PromiseWorkerResponseWrapper<Worker, Response>
- > = new Map<number, PromiseWorkerResponseWrapper<Worker, Response>>()
-
- /**
- * Id of the next message.
- */
- protected nextMessageId: number = 0
+ > = new Map<string, PromiseWorkerResponseWrapper<Worker, Response>>()
/**
* Worker choice strategy instance implementing the worker choice algorithm.
/**
* Worker choice strategy instance implementing the worker choice algorithm.
+ * Gets the given worker key.
*
* @param worker - The worker.
* @returns The worker key.
*
* @param worker - The worker.
* @returns The worker key.
/** {@inheritDoc} */
public async execute (data: Data): Promise<Response> {
/** {@inheritDoc} */
public async execute (data: Data): Promise<Response> {
- // Configure worker to handle message with the specified task
const worker = this.chooseWorker()
const worker = this.chooseWorker()
- const res = this.internalExecute(worker, this.nextMessageId)
+ const messageId = crypto.randomUUID()
+ const res = this.internalExecute(worker, messageId)
this.checkAndEmitBusy()
this.sendToWorker(worker, {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
data: data ?? ({} as Data),
this.checkAndEmitBusy()
this.sendToWorker(worker, {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
data: data ?? ({} as Data),
// eslint-disable-next-line @typescript-eslint/return-await
return res
}
// eslint-disable-next-line @typescript-eslint/return-await
return res
}
private async internalExecute (
worker: Worker,
private async internalExecute (
worker: Worker,
): Promise<Response> {
this.beforePromiseWorkerResponseHook(worker)
return await new Promise<Response>((resolve, reject) => {
): Promise<Response> {
this.beforePromiseWorkerResponseHook(worker)
return await new Promise<Response>((resolve, reject) => {
- * Get tasks usage of the given worker.
+ * Gets tasks usage of the given worker.
*
* @param worker - Worker which tasks usage is returned.
*/
*
* @param worker - Worker which tasks usage is returned.
*/
/**
* Id of the message.
*/
/**
* Id of the message.
*/