X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Futils.ts;h=d4649d70a56cc31dbb51ddf62aa3b79eca3ef4ef;hb=b7ea53bbd96886c5bc95c13943e5c92a3206f8a5;hp=e69725df102ed2ea083512b76f5dce75139a6894;hpb=80115618ce24038f504dc447dfb7c4fbd9c5d698;p=poolifier.git diff --git a/src/pools/utils.ts b/src/pools/utils.ts index e69725df..d4649d70 100644 --- a/src/pools/utils.ts +++ b/src/pools/utils.ts @@ -169,7 +169,7 @@ export const checkWorkerNodeArguments = ( } if (!isPlainObject(opts)) { throw new TypeError( - 'Cannot construct a worker node with invalid options: must be a plain object' + 'Cannot construct a worker node with invalid worker node options: must be a plain object' ) } if (opts.tasksQueueBackPressureSize == null) { @@ -202,6 +202,16 @@ export const checkWorkerNodeArguments = ( 'Cannot construct a worker node with a tasks queue bucket size option that is not a positive integer' ) } + if (opts.tasksQueuePriority == null) { + throw new TypeError( + 'Cannot construct a worker node without a tasks queue priority option' + ) + } + if (typeof opts.tasksQueuePriority !== 'boolean') { + throw new TypeError( + 'Cannot construct a worker node with a tasks queue priority option that is not a boolean' + ) + } } /** @@ -233,14 +243,18 @@ const updateMeasurementStatistics = ( measurementStatistics.maximum ?? Number.NEGATIVE_INFINITY ) if (measurementRequirements.average || measurementRequirements.median) { - measurementStatistics.history.push(measurementValue) + measurementStatistics.history.put(measurementValue) if (measurementRequirements.average) { - measurementStatistics.average = average(measurementStatistics.history) + measurementStatistics.average = average( + measurementStatistics.history.toArray() + ) } else if (measurementStatistics.average != null) { delete measurementStatistics.average } if (measurementRequirements.median) { - measurementStatistics.median = median(measurementStatistics.history) + measurementStatistics.median = median( + measurementStatistics.history.toArray() + ) } else if (measurementStatistics.median != null) { delete measurementStatistics.median }