From: Jérôme Benoit Date: Mon, 1 Apr 2024 15:08:16 +0000 (+0200) Subject: refactor(examples): trivial code cleanups X-Git-Tag: v3.1.29~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3fd93ff2ac708538e8a22ae329c5df210aaa51fe;p=poolifier.git refactor(examples): trivial code cleanups Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index 6f6e79c7..db52c8c2 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,8 @@ import { DynamicThreadPool, FixedThreadPool, PoolEvents, availableParallelism } // a fixed worker_threads pool const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) pool.emitter?.on(PoolEvents.ready, () => console.info('Pool is ready')) @@ -129,8 +129,8 @@ pool.emitter?.on(PoolEvents.busy, () => console.info('Pool is busy')) // or a dynamic worker_threads pool const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full')) diff --git a/examples/javascript/dynamicExample.cjs b/examples/javascript/dynamicExample.cjs index e170f59c..a72ce3a6 100644 --- a/examples/javascript/dynamicExample.cjs +++ b/examples/javascript/dynamicExample.cjs @@ -10,8 +10,8 @@ const pool = new DynamicThreadPool( availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) } ) let poolFull = 0 diff --git a/examples/javascript/fixedExample.cjs b/examples/javascript/fixedExample.cjs index 38e0c8af..f191aa24 100644 --- a/examples/javascript/fixedExample.cjs +++ b/examples/javascript/fixedExample.cjs @@ -6,8 +6,8 @@ const { } = require('poolifier') const pool = new FixedThreadPool(availableParallelism(), './yourWorker.cjs', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) let poolReady = 0 let poolBusy = 0 diff --git a/examples/javascript/multiFunctionExample.cjs b/examples/javascript/multiFunctionExample.cjs index 7ab57ab7..643d117a 100644 --- a/examples/javascript/multiFunctionExample.cjs +++ b/examples/javascript/multiFunctionExample.cjs @@ -5,8 +5,8 @@ const pool = new FixedThreadPool( availableParallelism(), './multiFunctionWorker.cjs', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) } ) diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index fb48f7b0..3965e1f0 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -18,11 +18,11 @@ const fixedPool = new FixedThreadPool( availableParallelism(), workerFile, { - errorHandler: (e: Error) => { - console.error(e) - }, onlineHandler: () => { console.info('Worker is online') + }, + errorHandler: (e: Error) => { + console.error(e) } } ) @@ -34,11 +34,11 @@ const dynamicPool = new DynamicThreadPool( availableParallelism(), workerFile, { - errorHandler: (e: Error) => { - console.error(e) - }, onlineHandler: () => { console.info('Worker is online') + }, + errorHandler: (e: Error) => { + console.error(e) } } )