| 1 | const { FixedThreadPool } = require('poolifier') |
| 2 | const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { |
| 3 | errorHandler: e => console.error(e), |
| 4 | onlineHandler: () => console.log('worker is online') |
| 5 | }) |
| 6 | |
| 7 | pool |
| 8 | .execute({ functionName: 'fn0', input: 'hello' }) |
| 9 | .then(res => console.log(res)) |
| 10 | .catch(err => console.error(err)) |
| 11 | pool |
| 12 | .execute({ functionName: 'fn1', input: 'multiple functions' }) |
| 13 | .then(res => console.log(res)) |
| 14 | .catch(err => console.error(err)) |
| 15 | |
| 16 | setTimeout(pool.destroy.bind(pool), 3000) |