X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultiFunctionExample.js;h=93d4e78b3d0465b35b823fd18dc2cbc203c66e31;hb=b3432a63039e7cb70c0448da5518690e457cd47e;hp=8b27f84154bcbb97b52cbee49f4074034aa0d04c;hpb=a3c8691eb5bd772a43746fd5860d54a786463039;p=poolifier.git diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index 8b27f841..93d4e78b 100644 --- a/examples/multiFunctionExample.js +++ b/examples/multiFunctionExample.js @@ -1,9 +1,16 @@ -const FixedThreadPool = require('../lib/fixed') -const pool = new FixedThreadPool(15, - './multifunctionWorker.js', - { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') }) +const { FixedThreadPool } = require('poolifier') +const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { + errorHandler: e => console.error(e), + onlineHandler: () => console.log('worker is online') +}) -pool.execute({ fname: 'fn0', input: 'hello' }).then(res => console.log(res)) -pool.execute({ fname: 'fn1', input: 'multifunction' }).then(res => console.log(res)) +pool + .execute({ functionName: 'fn0', input: 'hello' }) + .then(res => console.log(res)) + .catch(err => console.error(err)) +pool + .execute({ functionName: 'fn1', input: 'multiple functions' }) + .then(res => console.log(res)) + .catch(err => console.error(err)) setTimeout(pool.destroy.bind(pool), 3000)